Fix a memory leak when connecting to a database.
[GB.DB.ODBC] * BUG: Fix a memory leak when connecting to a database.
This commit is contained in:
parent
9abaadc360
commit
3c84b78d13
1 changed files with 7 additions and 2 deletions
|
@ -686,8 +686,10 @@ void GetConnectedDBName(DB_DESC *desc, ODBC_CONN *odbc)
|
||||||
|
|
||||||
if (SQL_SUCCEEDED(retcode))
|
if (SQL_SUCCEEDED(retcode))
|
||||||
{
|
{
|
||||||
dbName = malloc(sizeof(SQLTCHAR) * charsNeeded++);
|
charsNeeded++;
|
||||||
dbName[sizeof(SQLTCHAR) * charsNeeded++] = 0;
|
|
||||||
|
dbName = malloc(sizeof(SQLTCHAR) * charsNeeded);
|
||||||
|
|
||||||
/*zxMarce: We call the function again, this time specifying a
|
/*zxMarce: We call the function again, this time specifying a
|
||||||
hopefully big enough buffer for storing the catalog name.
|
hopefully big enough buffer for storing the catalog name.
|
||||||
*/
|
*/
|
||||||
|
@ -695,8 +697,11 @@ void GetConnectedDBName(DB_DESC *desc, ODBC_CONN *odbc)
|
||||||
dbName, charsNeeded,
|
dbName, charsNeeded,
|
||||||
&charsNeeded
|
&charsNeeded
|
||||||
);
|
);
|
||||||
|
dbName[sizeof(SQLTCHAR) * charsNeeded] = 0;
|
||||||
|
|
||||||
GB.FreeString(&desc->name);
|
GB.FreeString(&desc->name);
|
||||||
desc->name = GB.NewZeroString((char *)dbName);
|
desc->name = GB.NewZeroString((char *)dbName);
|
||||||
|
free(dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DB.IsDebug())
|
if (DB.IsDebug())
|
||||||
|
|
Loading…
Reference in a new issue