summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-07-05 13:13:45 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2013-07-05 13:13:45 +0200
commitce1b9cb4ba8917af1f2d16b20ab69a46af8fc5e4 (patch)
treefcbb4d723d8bd3b4f343712266c278b0149f87c1 /storage
parent923eddcfe12d015c43ee6422f32e000aadc714b8 (diff)
downloadmariadb-git-ce1b9cb4ba8917af1f2d16b20ab69a46af8fc5e4.tar.gz
- 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
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/domdoc.h1
-rw-r--r--storage/connect/ha_connect.cc13
-rw-r--r--storage/connect/ha_connect.h2
-rw-r--r--storage/connect/libdoc.cpp14
-rw-r--r--storage/connect/libdoc.h2
-rw-r--r--storage/connect/mycat.cc2
-rw-r--r--storage/connect/plgxml.h1
-rw-r--r--storage/connect/tabxml.cpp1
8 files changed, 28 insertions, 8 deletions
diff --git a/storage/connect/domdoc.h b/storage/connect/domdoc.h
index fc157950df8..0fd0a58ffdb 100644
--- a/storage/connect/domdoc.h
+++ b/storage/connect/domdoc.h
@@ -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);
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index f60a9d0d8f6..35cb0f03c3c 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -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
diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h
index 0d6354ca078..abf82b2d1a8 100644
--- a/storage/connect/ha_connect.h
+++ b/storage/connect/ha_connect.h
@@ -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);
diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp
index 02b931e2dc2..6e69322425e 100644
--- a/storage/connect/libdoc.cpp
+++ b/storage/connect/libdoc.cpp
@@ -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
diff --git a/storage/connect/libdoc.h b/storage/connect/libdoc.h
index 97f97f99ccc..7971f4d1395 100644
--- a/storage/connect/libdoc.h
+++ b/storage/connect/libdoc.h
@@ -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
/******************************************************************/
diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc
index 3dd203949b6..fe93751d600 100644
--- a/storage/connect/mycat.cc
+++ b/storage/connect/mycat.cc
@@ -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) {
diff --git a/storage/connect/plgxml.h b/storage/connect/plgxml.h
index 8fc95eabef7..b8352c36c14 100644
--- a/storage/connect/plgxml.h
+++ b/storage/connect/plgxml.h
@@ -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;
diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp
index 9b8db7abbab..69ad6711638 100644
--- a/storage/connect/tabxml.cpp
+++ b/storage/connect/tabxml.cpp
@@ -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