Commit ce1b9cb4 authored by Olivier Bertrand's avatar Olivier Bertrand

- 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
parent 923eddcf
......@@ -35,6 +35,7 @@ class DOMDOC : public XMLDOCUMENT {
// Properties
virtual short GetDocType(void) {return TYPE_FB_XML;}
virtual void *GetDocPtr(void) {return Docp;}
virtual void SetNofree(bool b) {} // Only libxml2
// Methods
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. */
/****************************************************************************/
void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf)
void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
{
const char *cp;
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
// To make valgring happy
pcf->Remark= (fp->comment.str && fp->comment.length) ?
fp->comment.str : NULL;
// Get the comment if any
if (fp->comment.str && fp->comment.length) {
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;
} // end of GetColumnOption
......
......@@ -154,7 +154,7 @@ public:
int GetIntegerOption(char *opname);
bool SetIntegerOption(char *opname, int n);
PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(void *field, PCOLINFO pcf);
void *GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf);
PIXDEF GetIndexInfo(void);
const char *GetDBName(const char *name);
const char *GetTableName(void);
......
......@@ -146,6 +146,8 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
Nlist = NULL;
Ctxp = NULL;
Xop = NULL;
Buf = NULL;
Nofreelist = false;
} // 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);
if (xp && xp->Count == 1) {
if (Nlist)
xmlXPathFreeNodeSet(Nlist);
if (Xop)
xmlXPathFreeObject(Xop);
......@@ -410,8 +415,13 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
if (trace)
htrc("Calling xmlXPathFreeNodeSetList Xop=%p\n", Xop);
xmlXPathFreeObject(Xop);
// xmlXPathFreeNodeSetList(Xop); // Caused memory leak
if (Nofreelist) {
// Making Nlist that must not be freed yet
xmlXPathFreeNodeSetList(Xop); // Caused memory leak
Nofreelist = false;
} else
xmlXPathFreeObject(Xop); // Caused node not found
} // endif Ctxp
// Set the context to the calling node
......
......@@ -37,6 +37,7 @@ class LIBXMLDOC : public XMLDOCUMENT {
// Properties
virtual short GetDocType(void) {return TYPE_FB_XML2;}
virtual void *GetDocPtr(void) {return Docp;}
virtual void SetNofree(bool b) {Nofreelist = b;}
// Methods
virtual bool Initialize(PGLOBAL g);
......@@ -64,6 +65,7 @@ class LIBXMLDOC : public XMLDOCUMENT {
xmlXPathContextPtr Ctxp;
xmlXPathObjectPtr Xop;
char *Buf; // Temporary
bool Nofreelist;
}; // end of class LIBXMLDOC
/******************************************************************/
......
......@@ -470,7 +470,7 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
} // endswitch tc
do {
field= Hc->GetColumnOption(field, pcf);
field= Hc->GetColumnOption(g, field, pcf);
} while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/));
if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) {
......
......@@ -69,6 +69,7 @@ class XMLDOCUMENT : public BLOCK {
// Properties
virtual short GetDocType(void) = 0;
virtual void *GetDocPtr(void) = 0;
virtual void SetNofree(bool b) = 0;
// Methods
virtual bool Initialize(PGLOBAL) = 0;
......
......@@ -547,6 +547,7 @@ bool TDBXML::Initialize(PGLOBAL g)
else
Nlist = TabNode->GetChildElements(g);
Docp->SetNofree(true); // For libxml2
#if defined(WIN32)
} catch(_com_error e) {
// We come here if a DOM command threw an error
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment