From: matteo at beccati dot com Operating system: * PHP version: 5.2.0 PHP Bug Type: PostgreSQL related Bug description: Memory leak in pg_get_notify
Description: ------------ While toying with the pgsql extesion I found that the pgsql_notify struct is not freed as pointed out in the PostgreSQL documentation: "After processing a PGnotify object returned by PQnotifies, be sure to free it with PQfreemem." (see: http://www.postgresql.org/docs/8.1/interactive/libpq-notify.html ). This could lead to memory leaks as far as I can see. Reproduce code: --------------- Here is the patch: --- ext/pgsql/pgsql.c 2006-10-06 23:45:10.000000000 +0200 +++ ext/pgsql/pgsql_new.c 2006-11-28 18:21:40.000000000 +0100 @@ -4347,6 +4347,8 @@ add_assoc_string(return_value, "message", pgsql_notify->relname, 1); add_assoc_long(return_value, "pid", pgsql_notify->be_pid); } + + PQfreemem(pgsql_notify); } /* }}} */ BTW, pg_*_bytea functions should use PQfreemem too, even if it is simply a wrapper. -- Edit bug report at http://bugs.php.net/?id=39663&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39663&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39663&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39663&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39663&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39663&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39663&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39663&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39663&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39663&r=support Expected behavior: http://bugs.php.net/fix.php?id=39663&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39663&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39663&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39663&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39663&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39663&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39663&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39663&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39663&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39663&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39663&r=mysqlcfg