mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
MFB: Fixed memory leaks when working with cursors in PDO PostgreSQL driver.
This commit is contained in:
parent
154507f6bc
commit
889f66837c
2 changed files with 4 additions and 0 deletions
|
@ -155,6 +155,9 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
|
||||||
PDO_CURSOR_FWDONLY TSRMLS_CC) == PDO_CURSOR_SCROLL;
|
PDO_CURSOR_FWDONLY TSRMLS_CC) == PDO_CURSOR_SCROLL;
|
||||||
|
|
||||||
if (scrollable) {
|
if (scrollable) {
|
||||||
|
if (S->cursor_name) {
|
||||||
|
efree(S->cursor_name);
|
||||||
|
}
|
||||||
/* TODO: check how scrollable cursors related to prepared statements */
|
/* TODO: check how scrollable cursors related to prepared statements */
|
||||||
spprintf(&S->cursor_name, 0, "pdo_pgsql_cursor_%08x", (unsigned int) stmt);
|
spprintf(&S->cursor_name, 0, "pdo_pgsql_cursor_%08x", (unsigned int) stmt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,7 @@ static int pgsql_stmt_fetch(pdo_stmt_t *stmt,
|
||||||
|
|
||||||
spprintf(&q, 0, "FETCH %s %ld FROM %s", ori_str, offset, S->cursor_name);
|
spprintf(&q, 0, "FETCH %s %ld FROM %s", ori_str, offset, S->cursor_name);
|
||||||
S->result = PQexec(S->H->server, q);
|
S->result = PQexec(S->H->server, q);
|
||||||
|
efree(q);
|
||||||
status = PQresultStatus(S->result);
|
status = PQresultStatus(S->result);
|
||||||
|
|
||||||
if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) {
|
if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue