php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60591 Memory leak when access a non-exists file
Submitted: 2011-12-22 07:18 UTC Modified: 2011-12-22 07:40 UTC
From: laruence@php.net Assigned: laruence
Status: Closed Package: Built-in web server
PHP Version: 5.4.0RC3 OS:
Private report: No CVE-ID:
 [2011-12-22 07:18 UTC] laruence@php.net
Description:
------------
report by cjones

if built-in server start with a router:
<?php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"]))
    return false; // serve the requested resource as-is.
else { 
    echo "here";
}
?>

then accesss a non-exists file like(a.jpe) will result in mem leak.

Test script:
---------------
<?php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"]))
    return false; // serve the requested resource as-is.
else { 
    echo "here";
}
?>

Expected result:
----------------
cjones@mlt:~/w$ php54 -S localhost:8000 routing.php 
PHP 5.4.0RC4-dev Development Server started at Mon Dec 19 18:55:25 2011
Listening on localhost:8000
Document root is /home/cjones/public_html
Press Ctrl-C to quit.
[Mon Dec 19 18:55:30 2011] ::1:48358 [200]: /oraclelogo.jpg
[Mon Dec 19 18:55:30 2011]  Script:  '/home/cjones/public_html/favicon.ico'
/home/cjones/phpsrc/php/php-src/branches/PHP_5_4/ext/filter/filter.c(451) :  
Freeing 0xB493F0E4 (16 bytes), script=/home/cjones/public_html/favicon.ico
Last leak repeated 19 times
[Mon Dec 19 18:55:30 2011]  Script:  '/home/cjones/public_html/favicon.ico'
/home/cjones/phpsrc/php/php-src/branches/PHP_5_4/Zend/zend_execute.h(184) :  
Freeing 0xB493F19C (65484 bytes), script=/home/cjones/public_html/favicon.ico
[Mon Dec 19 18:55:30 2011]  Script:  '/home/cjones/public_html/favicon.ico'

.....


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-22 07:39 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=321320
Log: Fix bug #60591 (Memory leak when access a non-exists file)
 [2011-12-22 07:40 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2011-12-22 07:40 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2011-12-22 08:08 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=321321
Log: test for bug 60591
 [2012-04-18 09:46 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=68147465afe6f0b024087f5d4a9443900605ead6
Log: Fix bug #60591 (Memory leak when access a non-exists file)
 [2012-07-24 23:37 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=68147465afe6f0b024087f5d4a9443900605ead6
Log: Fix bug #60591 (Memory leak when access a non-exists file)
 [2013-11-17 09:34 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=68147465afe6f0b024087f5d4a9443900605ead6
Log: Fix bug #60591 (Memory leak when access a non-exists file)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 05:03:21 2014 UTC