Re: Memory Leak in pgsql.c
| From: | Zeev Suraski | Date: | Fri, 10 Sep 1999 02:47:20 +0000 |
| Subject: | Re: Memory Leak in pgsql.c | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-10790@lists.php.net to get a copy of this message | ||
It may eliminate the memory leak warning, but it's not a valid fix - in
fact, it'll crash PHP very reliably under many circumstances.
I'll look at #2008.
Zeev
On Thu, 9 Sep 1999, Dominic J. Eidson wrote:
>
> 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@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
--
-----------------------------------------------------
Zeev Suraski <zeev@zend.com> http://www.zend.com/
For a PGP public key, finger bourbon@netvision.net.il