php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39663 Memory leak in pg_get_notify
Submitted: 2006-11-28 17:48 UTC Modified: 2006-11-29 15:47 UTC
From: matteo at beccati dot com Assigned: iliaa (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.2.0 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: matteo at beccati dot com
New email:
PHP Version: OS:

 

 [2006-11-28 17:48 UTC] matteo at beccati dot com
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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-29 15:47 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC