pollita Thu Jun 26 21:46:30 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/standard file.c /php-src/main streams.c Log: MFH: Plug memory leaks when freeing contexts (particularly options) Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.279.2.28 php-src/ext/standard/file.c:1.279.2.29 --- php-src/ext/standard/file.c:1.279.2.28 Thu Jun 26 21:32:26 2003 +++ php-src/ext/standard/file.c Thu Jun 26 21:46:30 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.279.2.28 2003/06/27 01:32:26 pollita Exp $ */ +/* $Id: file.c,v 1.279.2.29 2003/06/27 01:46:30 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -134,7 +134,12 @@ static ZEND_RSRC_DTOR_FUNC(file_context_dtor) { - php_stream_context_free((php_stream_context*)rsrc->ptr); + php_stream_context *context = (php_stream_context*)rsrc->ptr; + if (context->options) { + zval_ptr_dtor(&context->options); + context->options = NULL; + } + php_stream_context_free(context); } static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC) @@ -888,7 +893,6 @@ while (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(wval), (void**)&oval, &opos)) { if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_PP(wval), &okey, &okey_len, &num_key, 0, &opos)) { - ZVAL_ADDREF(*oval); php_stream_context_set_option(context, wkey, okey, *oval); } zend_hash_move_forward_ex(Z_ARRVAL_PP(wval), &opos); Index: php-src/main/streams.c diff -u php-src/main/streams.c:1.125.2.68 php-src/main/streams.c:1.125.2.69 --- php-src/main/streams.c:1.125.2.68 Fri May 30 21:37:44 2003 +++ php-src/main/streams.c Thu Jun 26 21:46:30 2003 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.125.2.68 2003/05/31 01:37:44 sniper Exp $ */ +/* $Id: streams.c,v 1.125.2.69 2003/06/27 01:46:30 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2819,7 +2819,10 @@ PHPAPI void php_stream_context_free(php_stream_context *context) { - zval_ptr_dtor(&context->options); + if (context->options) { + zval_ptr_dtor(&context->options); + context->options = NULL; + } efree(context); }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php