1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- Fix several bugs causing memory leak or invalid access detected

by Valgrind. This concerns the XML libxml2 support.

modified:
  storage/connect/domdoc.cpp
  storage/connect/domdoc.h
  storage/connect/ha_connect.cc
  storage/connect/libdoc.cpp
  storage/connect/plgdbsem.h
  storage/connect/plgxml.h
  storage/connect/tabxml.cpp
  storage/connect/tabxml.h
This commit is contained in:
Olivier Bertrand
2013-09-22 13:40:31 +02:00
parent bd37d644d6
commit 65b0e5455b
8 changed files with 191 additions and 45 deletions

View File

@@ -78,7 +78,9 @@ XMLDEF::XMLDEF(void)
DefNs = NULL;
Attrib = NULL;
Hdattr = NULL;
Coltype = 1;
Limit = 0;
Header = 0;
Xpand = false;
Usedom = false;
} // end of XMLDEF constructor
@@ -338,17 +340,14 @@ PCOL TDBXML::InsertSpecialColumn(PGLOBAL g, PCOL colp)
/***********************************************************************/
/* LoadTableFile: Load and parse an XML file. */
/***********************************************************************/
int TDBXML::LoadTableFile(PGLOBAL g)
int TDBXML::LoadTableFile(PGLOBAL g, char *filename)
{
char filename[_MAX_PATH];
int rc = RC_OK, type = (Usedom) ? TYPE_FB_XML : TYPE_FB_XML2;
PFBLOCK fp = NULL;
PDBUSER dup = (PDBUSER)g->Activityp->Aptr;
/*********************************************************************/
/* We used the file name relative to recorded datapath. */
/*********************************************************************/
PlugSetPath(filename, Xfile, GetPath());
if (Docp)
return rc; // Already done
if (trace)
htrc("TDBXML: loading %s\n", filename);
@@ -397,6 +396,7 @@ int TDBXML::LoadTableFile(PGLOBAL g)
} else
rc = (errno == ENOENT) ? RC_NF : RC_INFO;
// Cannot make a Xblock until document is made
return rc;
} // endif Docp
@@ -418,9 +418,8 @@ int TDBXML::LoadTableFile(PGLOBAL g)
/***********************************************************************/
bool TDBXML::Initialize(PGLOBAL g)
{
char tabpath[64];
int rc;
PXMLCOL colp;
int rc;
PXMLCOL colp;
if (Void)
return false;
@@ -440,8 +439,13 @@ bool TDBXML::Initialize(PGLOBAL g)
#else
if (!Root) {
#endif
char tabpath[64], filename[_MAX_PATH];
// We used the file name relative to recorded datapath
PlugSetPath(filename, Xfile, GetPath());
// Load or re-use the table file
rc = LoadTableFile(g);
rc = LoadTableFile(g, filename);
if (rc == RC_OK) {
// Get root node
@@ -503,6 +507,9 @@ bool TDBXML::Initialize(PGLOBAL g)
goto error;
} // endif NewDoc
// Now we can link the Xblock
To_Xb = Docp->LinkXblock(g, Mode, rc, filename);
// Add a CONNECT comment node
// sprintf(buf, MSG(CREATED_PLUGDB), version);
sprintf(buf, " Created by CONNECT %s ", version);
@@ -893,12 +900,21 @@ int TDBXML::DeleteDB(PGLOBAL g, int irc)
if ((RowNode = Nlist->GetItem(g, Irow, RowNode)) == NULL) {
sprintf(g->Message, MSG(MISSING_ROWNODE), Irow);
return RC_FX;
} else
} else {
TabNode->DeleteChild(g, RowNode);
if (Nlist->DropItem(g, Irow))
return RC_FX;
} // endif RowNode
Changed = true;
} else if (irc != RC_EF) {
TabNode->DeleteChild(g, RowNode);
if (Nlist->DropItem(g, Irow))
return RC_FX;
Changed = true;
} // endif's irc