Fix memory leak exhibited by bug_aaa.phpt

Since a statement may be executed multiple times, we need to free
already allocated storage for output data before allocating new
storage.
This commit is contained in:
Christoph M. Becker 2019-05-04 09:42:07 +02:00
parent ba0913a2e5
commit ae21dc46da

View file

@ -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)];
}