Fixed bug #75402 Possible Memory Leak using PDO::CURSOR_SCROLL option

This commit is contained in:
Anatol Belski 2018-07-30 18:27:59 +02:00
parent ed7e3bc70a
commit cc69950b15
2 changed files with 119 additions and 0 deletions

View file

@ -165,6 +165,7 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt)
pdo_pgsql_error_stmt(stmt, status, pdo_pgsql_sqlstate(S->result));
return 0;
}
PQclear(S->result);
/* the cursor was declared correctly */
S->is_prepared = 1;
@ -434,6 +435,11 @@ static int pgsql_stmt_fetch(pdo_stmt_t *stmt,
return 0;
}
if(S->result) {
PQclear(S->result);
S->result = NULL;
}
spprintf(&q, 0, "FETCH %s FROM %s", ori_str, S->cursor_name);
efree(ori_str);
S->result = PQexec(S->H->server, q);