mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- Try to fix a uninitialised valgrind warning
modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/mycat.cc - Fix a regression error on XML libdoc wrong Nlist freing modified: storage/connect/domdoc.h storage/connect/libdoc.cpp storage/connect/libdoc.h storage/connect/plgxml.h storage/connect/tabxml.cpp
This commit is contained in:
@@ -35,6 +35,7 @@ class DOMDOC : public XMLDOCUMENT {
|
|||||||
// Properties
|
// Properties
|
||||||
virtual short GetDocType(void) {return TYPE_FB_XML;}
|
virtual short GetDocType(void) {return TYPE_FB_XML;}
|
||||||
virtual void *GetDocPtr(void) {return Docp;}
|
virtual void *GetDocPtr(void) {return Docp;}
|
||||||
|
virtual void SetNofree(bool b) {} // Only libxml2
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual bool Initialize(PGLOBAL g);
|
virtual bool Initialize(PGLOBAL g);
|
||||||
|
@@ -851,7 +851,7 @@ PFOS ha_connect::GetFieldOptionStruct(Field *fdp)
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Returns the column description structure used to make the column. */
|
/* Returns the column description structure used to make the column. */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf)
|
void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
|
||||||
{
|
{
|
||||||
const char *cp;
|
const char *cp;
|
||||||
ha_field_option_struct *fop;
|
ha_field_option_struct *fop;
|
||||||
@@ -983,9 +983,14 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf)
|
|||||||
|
|
||||||
pcf->Key= 0; // Not used when called from MySQL
|
pcf->Key= 0; // Not used when called from MySQL
|
||||||
|
|
||||||
// To make valgring happy
|
// Get the comment if any
|
||||||
pcf->Remark= (fp->comment.str && fp->comment.length) ?
|
if (fp->comment.str && fp->comment.length) {
|
||||||
fp->comment.str : NULL;
|
pcf->Remark= (char*)PlugSubAlloc(g, NULL, fp->comment.length + 1);
|
||||||
|
memcpy(pcf->Remark, fp->comment.str, fp->comment.length);
|
||||||
|
pcf->Remark[fp->comment.length] = 0;
|
||||||
|
} else
|
||||||
|
pcf->Remark= NULL;
|
||||||
|
|
||||||
return fldp;
|
return fldp;
|
||||||
} // end of GetColumnOption
|
} // end of GetColumnOption
|
||||||
|
|
||||||
|
@@ -154,7 +154,7 @@ public:
|
|||||||
int GetIntegerOption(char *opname);
|
int GetIntegerOption(char *opname);
|
||||||
bool SetIntegerOption(char *opname, int n);
|
bool SetIntegerOption(char *opname, int n);
|
||||||
PFOS GetFieldOptionStruct(Field *fp);
|
PFOS GetFieldOptionStruct(Field *fp);
|
||||||
void *GetColumnOption(void *field, PCOLINFO pcf);
|
void *GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf);
|
||||||
PIXDEF GetIndexInfo(void);
|
PIXDEF GetIndexInfo(void);
|
||||||
const char *GetDBName(const char *name);
|
const char *GetDBName(const char *name);
|
||||||
const char *GetTableName(void);
|
const char *GetTableName(void);
|
||||||
|
@@ -146,6 +146,8 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
|
|||||||
Nlist = NULL;
|
Nlist = NULL;
|
||||||
Ctxp = NULL;
|
Ctxp = NULL;
|
||||||
Xop = NULL;
|
Xop = NULL;
|
||||||
|
Buf = NULL;
|
||||||
|
Nofreelist = false;
|
||||||
} // end of LIBXMLDOC constructor
|
} // end of LIBXMLDOC constructor
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
@@ -347,6 +349,9 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
|
|||||||
htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0);
|
htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0);
|
||||||
|
|
||||||
if (xp && xp->Count == 1) {
|
if (xp && xp->Count == 1) {
|
||||||
|
if (Nlist)
|
||||||
|
xmlXPathFreeNodeSet(Nlist);
|
||||||
|
|
||||||
if (Xop)
|
if (Xop)
|
||||||
xmlXPathFreeObject(Xop);
|
xmlXPathFreeObject(Xop);
|
||||||
|
|
||||||
@@ -410,8 +415,13 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
|
|||||||
if (trace)
|
if (trace)
|
||||||
htrc("Calling xmlXPathFreeNodeSetList Xop=%p\n", Xop);
|
htrc("Calling xmlXPathFreeNodeSetList Xop=%p\n", Xop);
|
||||||
|
|
||||||
xmlXPathFreeObject(Xop);
|
if (Nofreelist) {
|
||||||
// xmlXPathFreeNodeSetList(Xop); // Caused memory leak
|
// Making Nlist that must not be freed yet
|
||||||
|
xmlXPathFreeNodeSetList(Xop); // Caused memory leak
|
||||||
|
Nofreelist = false;
|
||||||
|
} else
|
||||||
|
xmlXPathFreeObject(Xop); // Caused node not found
|
||||||
|
|
||||||
} // endif Ctxp
|
} // endif Ctxp
|
||||||
|
|
||||||
// Set the context to the calling node
|
// Set the context to the calling node
|
||||||
|
@@ -37,6 +37,7 @@ class LIBXMLDOC : public XMLDOCUMENT {
|
|||||||
// Properties
|
// Properties
|
||||||
virtual short GetDocType(void) {return TYPE_FB_XML2;}
|
virtual short GetDocType(void) {return TYPE_FB_XML2;}
|
||||||
virtual void *GetDocPtr(void) {return Docp;}
|
virtual void *GetDocPtr(void) {return Docp;}
|
||||||
|
virtual void SetNofree(bool b) {Nofreelist = b;}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual bool Initialize(PGLOBAL g);
|
virtual bool Initialize(PGLOBAL g);
|
||||||
@@ -64,6 +65,7 @@ class LIBXMLDOC : public XMLDOCUMENT {
|
|||||||
xmlXPathContextPtr Ctxp;
|
xmlXPathContextPtr Ctxp;
|
||||||
xmlXPathObjectPtr Xop;
|
xmlXPathObjectPtr Xop;
|
||||||
char *Buf; // Temporary
|
char *Buf; // Temporary
|
||||||
|
bool Nofreelist;
|
||||||
}; // end of class LIBXMLDOC
|
}; // end of class LIBXMLDOC
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
@@ -470,7 +470,7 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
|
|||||||
} // endswitch tc
|
} // endswitch tc
|
||||||
|
|
||||||
do {
|
do {
|
||||||
field= Hc->GetColumnOption(field, pcf);
|
field= Hc->GetColumnOption(g, field, pcf);
|
||||||
} while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/));
|
} while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/));
|
||||||
|
|
||||||
if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) {
|
if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) {
|
||||||
|
@@ -69,6 +69,7 @@ class XMLDOCUMENT : public BLOCK {
|
|||||||
// Properties
|
// Properties
|
||||||
virtual short GetDocType(void) = 0;
|
virtual short GetDocType(void) = 0;
|
||||||
virtual void *GetDocPtr(void) = 0;
|
virtual void *GetDocPtr(void) = 0;
|
||||||
|
virtual void SetNofree(bool b) = 0;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual bool Initialize(PGLOBAL) = 0;
|
virtual bool Initialize(PGLOBAL) = 0;
|
||||||
|
@@ -547,6 +547,7 @@ bool TDBXML::Initialize(PGLOBAL g)
|
|||||||
else
|
else
|
||||||
Nlist = TabNode->GetChildElements(g);
|
Nlist = TabNode->GetChildElements(g);
|
||||||
|
|
||||||
|
Docp->SetNofree(true); // For libxml2
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
} catch(_com_error e) {
|
} catch(_com_error e) {
|
||||||
// We come here if a DOM command threw an error
|
// We come here if a DOM command threw an error
|
||||||
|
Reference in New Issue
Block a user