|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 Patchesparse_ini_file_memleak.patch (last revision 2012-02-23 17:32 UTC by nikic@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits              [2012-02-14 18:00 UTC] nikic@php.net
  [2012-02-16 02:16 UTC] laruence@php.net
 
-Assigned To:
+Assigned To: laruence
  [2012-02-23 17:32 UTC] nikic@php.net
  [2012-02-25 14:15 UTC] laruence@php.net
  [2012-03-02 03:51 UTC] laruence@php.net
  [2012-03-02 03:52 UTC] laruence@php.net
 
-Status: Assigned
+Status: Closed
  [2012-03-02 03:52 UTC] laruence@php.net
  [2012-04-18 09:45 UTC] laruence@php.net
  [2012-07-24 23:37 UTC] rasmus@php.net
  [2013-11-17 09:33 UTC] laruence@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Sat Oct 25 02:00:01 2025 UTC | 
Description: ------------ parse_ini_file('emptyFile', false, 26); Leaks: Warning: Invalid scanner mode in /home/nikic/dev/my- fuzzer/reproduceCode5_memoryLeak.php on line 3 [Tue Feb 14 18:36:56 2012] Script: 'reproduceCode5_memoryLeak.php' /home/nikic/dev/php-src/main/streams/plain_wrapper.c(910) : Freeing 0xB780BE94 (36 bytes), script=reproduceCode5_memoryLeak.php [Tue Feb 14 18:36:56 2012] Script: 'reproduceCode5_memoryLeak.php' /home/nikic/dev/php-src/Zend/zend_stream.c(280) : Freeing 0xB780C908 (32 bytes), script=reproduceCode5_memoryLeak.php === Total 2 memory leaks detected === The reason is that the file handle is not closed correctly. I was able to fix it using this simple patch: diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c index 85fc74d..3b4e217 100644 --- a/Zend/zend_ini_scanner.c +++ b/Zend/zend_ini_scanner.c @@ -230,9 +230,12 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, i char *buf; size_t size; - if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE || - init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE - ) { + if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) { + return FAILURE; + } + + if (init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE) { + zend_file_handle_dtor(fh TSRMLS_CC); return FAILURE; }