From: Ilia Alshanetsky Date: Thu, 19 Jun 2003 16:35:29 +0000 (+0000) Subject: MFH: Fixed memory leak, when invalid context is specified. X-Git-Tag: php-4.3.3RC2~272 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e39472c6063ca1af4bd2bd3eec78d9804af355d0;p=php MFH: Fixed memory leak, when invalid context is specified. --- diff --git a/ext/standard/file.c b/ext/standard/file.c index aaf2359f58..f783c43cac 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -905,10 +905,10 @@ static int parse_context_options(php_stream_context *context, zval *options) static int parse_context_params(php_stream_context *context, zval *params) { - int ret = SUCCESS; + int ret = FAILURE; zval **tmp; - if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "notification", sizeof("notification"), (void**)&tmp)) { + if ((ret = zend_hash_find(Z_ARRVAL_P(params), "notification", sizeof("notification"), (void**)&tmp)) == SUCCESS) { if (context->notifier) { php_stream_notification_free(context->notifier); @@ -920,10 +920,14 @@ static int parse_context_params(php_stream_context *context, zval *params) context->notifier->ptr = *tmp; ZVAL_ADDREF(*tmp); } - if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) { + if ((ret = zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) == SUCCESS) { parse_context_options(context, *tmp); } - + + if (ret != SUCCESS) { + php_stream_context_free(context); + } + return ret; }