php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24700 small memory leaks found by valgrind
Submitted: 2003-07-18 01:55 UTC Modified: 2003-07-18 07:05 UTC
From: jan at kneschke dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.3RC1 OS: Linux 2.4.x
Private report: No CVE-ID: None
 [2003-07-18 01:55 UTC] jan at kneschke dot de
Description:
------------
I just used valgrind on a simple php script and found a small 
memory leaks in the Zend Engine 
 
A patch is attached below. 
 
1. double init of auto_globals in line 473 and 499 because of 
#ifndef ZTS  
 #define GLOBAL_AUTO_GLOBALS_TABLE        
CG(auto_globals) 
#endif 
 
2. a missing free 

Reproduce code:
---------------
$ valgrind --logfile-fd=1 -v --leak-check=yes --show-reachable=yes ~/projects/in-cvs/php4/sapi/cli/php -r "print 'a';"

Expected result:
----------------
no leaks :) 

Actual result:
--------------
Index: Zend/zend.c 
=================================================================== 
RCS file: /repository/Zend/Attic/zend.c,v 
retrieving revision 1.162.2.9 
diff -u -r1.162.2.9 zend.c 
--- Zend/zend.c 14 Jun 2003 09:27:34 -0000      1.162.2.9 
+++ Zend/zend.c 18 Jul 2003 06:47:51 -0000 
@@ -496,7 +496,6 @@ 
        zend_startup_constants(tsrm_ls); 
        GLOBAL_CONSTANTS_TABLE = EG(zend_constants); 
 #else 
-       zend_hash_init_ex(CG(auto_globals), 8, NULL, NULL, 1, 
0); 
        scanner_globals_ctor(&ini_scanner_globals 
TSRMLS_CC); 
        scanner_globals_ctor(&language_scanner_globals 
TSRMLS_CC); 
        zend_startup_constants(); 
Index: Zend/zend_ini.c 
=================================================================== 
RCS file: /repository/Zend/Attic/zend_ini.c,v 
retrieving revision 1.23.2.2 
diff -u -r1.23.2.2 zend_ini.c 
--- Zend/zend_ini.c     24 Mar 2003 14:53:13 -0000      
1.23.2.2 
+++ Zend/zend_ini.c     18 Jul 2003 06:47:52 -0000 
@@ -78,6 +78,7 @@ 
 ZEND_API int zend_ini_shutdown(TSRMLS_D) 
 { 
        zend_hash_destroy(EG(ini_directives)); 
+       free(EG(ini_directives)); 
        return SUCCESS; 
 } 
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-18 07:05 UTC] sniper@php.net
Patch applied.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 08 16:01:33 2025 UTC