Skip to content

Commit

Permalink
Fix of the memory leak. It could occur if prepare, or direct executio…
Browse files Browse the repository at this point in the history
…n in case of 10.2, failed, and Stmt handler reused.

Alse removed unused field from Stmt struct and its references(was only
freed in few places).
  • Loading branch information
lawrinn committed Oct 6, 2017
1 parent 6265daf commit 9069741
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion ma_odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ struct st_ma_odbc_stmt
MADB_DescRecord *PutDataRec;
MADB_Stmt *DaeStmt;
char *StmtString;
char *NativeSql;
MADB_Stmt *PositionedCursor;
my_bool PositionedCommand;
enum MADB_StmtState State;
Expand Down
7 changes: 4 additions & 3 deletions ma_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ SQLRETURN MADB_StmtFree(MADB_Stmt *Stmt, SQLUSMALLINT Option)
MADB_FREE(Stmt->result);
MADB_FREE(Stmt->Cursor.Name);
MADB_FREE(Stmt->StmtString);
MADB_FREE(Stmt->NativeSql);
MADB_FREE(Stmt->CatalogName);
MADB_FREE(Stmt->TableName);
ResetMetadata(&Stmt->metadata, NULL);
Expand Down Expand Up @@ -334,7 +333,6 @@ SQLRETURN MADB_StmtExecDirect(MADB_Stmt *Stmt, char *StatementText, SQLINTEGER T
else
{
MADB_FREE(Stmt->StmtString);
MADB_FREE(Stmt->NativeSql);
return ret;
}
}
Expand Down Expand Up @@ -426,9 +424,12 @@ void MADB_StmtReset(MADB_Stmt *Stmt)
Stmt->Ird->Header.Count= 0;

case MADB_SS_EMULATED:
/* We can have the case, then query did not succeed, and in case of direct execution we wouldn't
have ane state set, but some of stuff still needs to be cleaned. Perhaps we could introduce a state
for such case, smth like DIREXEC_PREPARED. Would be more proper, but yet overkill */
default:
Stmt->PositionedCommand= 0;
Stmt->QueryType= MADB_QUERY_NO_RESULT;
MADB_FREE(Stmt->NativeSql);
MADB_FREE(Stmt->StmtString);
Stmt->State= MADB_SS_INITED;
MADB_CLEAR_ERROR(&Stmt->Error);
Expand Down

0 comments on commit 9069741

Please sign in to comment.