[PHP-DEV] Memory Leak in pgsql.c From: Dominic J. Eidson (sauron <email protected>)
Date: 09/09/99

There is a bug on bugs.php.net (ID 2008), reporting a memory leak in
pgsql.c line 915 - I also found this, and in the latest CVS code it is at
line 919 (element = safe_estrndup(element,element_len);).

Below is the fix (at least it gets rid of the memory leak warning).

Index: php4/ext/pgsql/pgsql.c
===================================================================
RCS file: /repository/php4/ext/pgsql/pgsql.c,v
retrieving revision 1.17
diff -u -r1.17 pgsql.c
--- php4/ext/pgsql/pgsql.c 1999/09/04 13:18:55 1.17
+++ php4/ext/pgsql/pgsql.c 1999/09/10 02:27:10
@@ -940,6 +940,7 @@
                                 field_name = PQfname(pgsql_result,i);
                                 add_assoc_stringl(return_value, field_name, data, data_len, should_copy);
                         }
+ efree(element);
         } else {
             /* NULL field, don't set it */
             /* add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr); */

-- 
Dominic J. Eidson
                                         "Baruk Khazad! Khazad ai-menu!" - Gimli
--------------------------------------------------------------------------------
http://www.the-infinite.org/               http://www.the-infinite.org/~dominic/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>