]> granicus.if.org Git - php/commitdiff
MFB: Fixed memory leaks when working with cursors in PDO PostgreSQL driver.
authorIlia Alshanetsky <iliaa@php.net>
Mon, 8 May 2006 14:33:23 +0000 (14:33 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 8 May 2006 14:33:23 +0000 (14:33 +0000)
ext/pdo_pgsql/pgsql_driver.c
ext/pdo_pgsql/pgsql_statement.c

index bbbfa4d3da54d8ab83287b4b261558ecc0d3d229..37c8e67144542344773bfbd54c615b9eeca5caac 100644 (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;
 
        if (scrollable) {
+               if (S->cursor_name) {
+                       efree(S->cursor_name);
+               }
                /* TODO: check how scrollable cursors related to prepared statements */
                spprintf(&S->cursor_name, 0, "pdo_pgsql_cursor_%08x", (unsigned int) stmt);
        }
index a3f9f908e001c3a19b4cab4f55fe86c9ed9623b9..e6499d73a174ed7177ffb1294be7b80937581968 100644 (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);
                S->result = PQexec(S->H->server, q);
+               efree(q);
                status = PQresultStatus(S->result);
 
                if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) {