From: Xinchen Hui Date: Tue, 4 Mar 2014 12:25:26 +0000 (+0800) Subject: Fixed memory leak X-Git-Tag: POST_PHPNG_MERGE~412^2~421^2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1ec21e265420d1664a9e417e66fbf34ff49a73d;p=php Fixed memory leak --- diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index b8724dea55..8682e1f7fa 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -414,13 +414,17 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC) format_offset = 0; } - convert_to_string_ex(&args[format_offset]); + if (Z_TYPE(args[format_offset]) != IS_STRING) { + convert_to_string(&args[format_offset]); + } else if (Z_REFCOUNTED(args[format_offset])) { + Z_ADDREF(args[format_offset]); + } format = Z_STRVAL(args[format_offset]); result = STR_ALLOC(size, 0); currarg = 1; - while (inpos= argc) { efree(result); + zval_dtor(&args[format_offset]); efree(args); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too few arguments"); return NULL; @@ -649,6 +657,7 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC) } } + zval_dtor(&args[format_offset]); efree(args); /* possibly, we have to make sure we have room for the terminating null? */