MFB: Fixed memory leaks when working with cursors in PDO PostgreSQL driver.

This commit is contained in:
Ilia Alshanetsky 2006-05-08 14:33:23 +00:00
parent 154507f6bc
commit 889f66837c
2 changed files with 4 additions and 0 deletions

View file

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

View file

@ -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) {