PHP 4.0 Bug #9377 Updated: memory leaks on error in array_push() and array_unshift()

From: Date: Wed, 21 Feb 2001 17:24:20 +0000
Subject: PHP 4.0 Bug #9377 Updated: memory leaks on error in array_push() and array_unshift()
Groups: php.dev 
Request: Send a blank email to php-dev+get-47154@lists.php.net to get a copy of this message
ID: 9377 Updated by: andrei Reported By: chris@nameboy.com Old-Status: Open Status: Closed Bug Type: Arrays related Assigned To: Comments: Applied, thanks. Previous Comments: --------------------------------------------------------------------------- [2001-02-21 12:20:52] chris@nameboy.com Both array_push() and array_unshift() leak memory when called with a non-array first parameter (which generates an error, of course) For example: <? $abc = 0; for($i=0; $i<5000000; $i++) { @array_push($abc, 123); } ?> Patch follows... --- php-4.0.4pl1/ext/standard/array.c.ORIG Wed Feb 21 09:07:13 2001 +++ php-4.0.4pl1/ext/standard/array.c Wed Feb 21 08:59:59 2001 @@ -1501,6 +1501,7 @@ stack = *args[0]; if (Z_TYPE_P(stack) != IS_ARRAY) { php_error(E_WARNING, "First argument to array_push() needs to be an array"); + efree(args); RETURN_FALSE; } @@ -1605,6 +1606,7 @@ stack = *args[0]; if (Z_TYPE_P(stack) != IS_ARRAY) { php_error(E_WARNING, "First argument to array_unshift() needs to be an array"); + efree(args); RETURN_FALSE; } --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=9377&edit=2

« previous php.dev (#47154) next »