From: Ilia Alshanetsky Date: Thu, 14 Aug 2003 17:49:48 +0000 (+0000) Subject: MFH: Fixed bug #25093 (Various leaks due to non-freed queries) X-Git-Tag: php-4.3.3RC4~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=903275e88751e8be58cd8f393b5cd28d304dc931;p=php MFH: Fixed bug #25093 (Various leaks due to non-freed queries) --- diff --git a/NEWS b/NEWS index e387939473..627e4a87f5 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP 4 NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 14 Aug 2003, Version 4.3.3RC4 +- Fixed bug #25093 (Various leaks due to non-freed queries). (Ilia) - Fixed bug #25084 (Make refer check not dependant on register_globals). (Ilia) - Fixed bug #25081 (odbc_fetch_array() may mangle numeric fields). (Ilia) - Fixed bug #25044 (header("Location:") changing HTTP status). (Marcus) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 175a7c5d84..0f43f35dec 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -962,6 +962,7 @@ PHP_FUNCTION(pg_query) case PGRES_NONFATAL_ERROR: case PGRES_FATAL_ERROR: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s.", PQerrorMessage(pgsql)); + PQclear(pgsql_result); RETURN_FALSE; break; case PGRES_COMMAND_OK: /* successful command that did not return rows */ @@ -973,6 +974,7 @@ PHP_FUNCTION(pg_query) pg_result->row = 0; ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result); } else { + PQclear(pgsql_result); RETURN_FALSE; } break; @@ -1119,6 +1121,7 @@ static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list TSRMLS_DC) ret = estrdup(tmp_name); } } + PQclear(result); } smart_str_free(&str); @@ -3173,6 +3176,7 @@ PHPAPI int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *me name = PQgetvalue(pg_result,i,0); add_assoc_zval(meta, name, elem); } + PQclear(pg_result); return SUCCESS; } @@ -4003,6 +4007,7 @@ static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, ulong opt T pg_result = PQexec(pg_link, querystr->c); if (PQresultStatus(pg_result) == expect) { + PQclear(pg_result); return 0; } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to execute '%s'.", querystr->c); @@ -4472,9 +4477,9 @@ PHPAPI int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids_array, ret = php_pgsql_result2array(pg_result, ret_array TSRMLS_CC); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to execute '%s'.", querystr.c); - PQclear(pg_result); } - + PQclear(pg_result); + cleanup: if (!(opt & PGSQL_DML_NO_CONV)) { zval_dtor(ids_converted);