Skip to content

Commit

Permalink
Fix memory leak exhibited by bug_aaa.phpt
Browse files Browse the repository at this point in the history
Since a statement may be executed multiple times, we need to free
already allocated storage for output data before allocating new
storage.
  • Loading branch information
cmb69 committed May 4, 2019
1 parent ba0913a commit ae21dc4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/pdo_firebird/firebird_statement.c
Original file line number Diff line number Diff line change
@@ -104,6 +104,9 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt) /* {{{ */
unsigned int i;
for (i = 0; i < S->out_sqlda.sqld; i++) {
XSQLVAR *var = &S->out_sqlda.sqlvar[i];
if (var->sqlind) {
efree(var->sqlind);
}
var->sqlind = (void*)ecalloc(1, var->sqllen + 2 * sizeof(short));
var->sqldata = &((char*)var->sqlind)[sizeof(short)];
}

0 comments on commit ae21dc4

Please sign in to comment.