mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-11-26 10:29:27 +08:00
Memory leak fix in odbc
Free the stmt->bind_head list on Stmt Reset row_affected on FreeStmt
This commit is contained in:
committed by
Nirgal Vourgère
parent
6326e54e82
commit
6043e22a43
@@ -55,6 +55,7 @@ static SQLRETURN SQL_API _SQLFreeEnv(SQLHENV henv);
|
|||||||
static SQLRETURN SQL_API _SQLFreeStmt(SQLHSTMT hstmt, SQLUSMALLINT fOption);
|
static SQLRETURN SQL_API _SQLFreeStmt(SQLHSTMT hstmt, SQLUSMALLINT fOption);
|
||||||
|
|
||||||
static void bind_columns (struct _hstmt*);
|
static void bind_columns (struct _hstmt*);
|
||||||
|
static void unbind_columns (struct _hstmt*);
|
||||||
|
|
||||||
#define FILL_FIELD(f,v,s) mdb_fill_temp_field(f,v,s,0,0,0,0)
|
#define FILL_FIELD(f,v,s) mdb_fill_temp_field(f,v,s,0,0,0,0)
|
||||||
|
|
||||||
@@ -1125,6 +1126,8 @@ bind_columns(struct _hstmt *stmt)
|
|||||||
struct _henv *env = (struct _henv *) dbc->henv;
|
struct _henv *env = (struct _henv *) dbc->henv;
|
||||||
struct _sql_bind_info *cur;
|
struct _sql_bind_info *cur;
|
||||||
|
|
||||||
|
TRACE("bind_columns");
|
||||||
|
|
||||||
if (stmt->rows_affected==0) {
|
if (stmt->rows_affected==0) {
|
||||||
cur = stmt->bind_head;
|
cur = stmt->bind_head;
|
||||||
while (cur) {
|
while (cur) {
|
||||||
@@ -1140,6 +1143,23 @@ bind_columns(struct _hstmt *stmt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unbind_columns(struct _hstmt *stmt)
|
||||||
|
{
|
||||||
|
struct _sql_bind_info *cur, *next;
|
||||||
|
|
||||||
|
TRACE("unbind_columns");
|
||||||
|
|
||||||
|
//Free the memory allocated for bound columns
|
||||||
|
cur = stmt->bind_head;
|
||||||
|
while(cur) {
|
||||||
|
next = cur->next;
|
||||||
|
g_free(cur);
|
||||||
|
cur = next;
|
||||||
|
}
|
||||||
|
stmt->bind_head = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SQLRETURN SQL_API SQLFetch(
|
SQLRETURN SQL_API SQLFetch(
|
||||||
SQLHSTMT hstmt)
|
SQLHSTMT hstmt)
|
||||||
{
|
{
|
||||||
@@ -1230,8 +1250,14 @@ static SQLRETURN SQL_API _SQLFreeStmt(
|
|||||||
TRACE("_SQLFreeStmt");
|
TRACE("_SQLFreeStmt");
|
||||||
if (fOption==SQL_DROP) {
|
if (fOption==SQL_DROP) {
|
||||||
mdb_sql_reset(sql);
|
mdb_sql_reset(sql);
|
||||||
|
unbind_columns(stmt);
|
||||||
g_free(stmt);
|
g_free(stmt);
|
||||||
} else if (fOption==SQL_CLOSE) {
|
} else if (fOption==SQL_CLOSE) {
|
||||||
|
stmt->rows_affected = 0;
|
||||||
|
} else if (fOption==SQL_UNBIND) {
|
||||||
|
unbind_columns(stmt);
|
||||||
|
} else if (fOption==SQL_RESET_PARAMS) {
|
||||||
|
/* Bound parameters not currently implemented */
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user