# [PATCH] Memory leak reported by ccmalloc

- Thread: https://externals.io/message/4163
- Original archive: https://news-web.php.net/php.internals/4163
- Started by Vesselin Atanasov on 2003-08-25T07:10:09+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #4163 — Vesselin Atanasov — 2003-08-25T07:10:09+00:00

URL: https://externals.io/message/4163#4163

Hello.
I compiled PHP with ccmalloc (a memory leak detector) and it reported two memory leaks.
Here is a patch that meakes the leak reports go away. Actually only the first two
allocations (GLOBAL_FUNCTION_TABLE and GLOBAL_CLASS_TABLE) are reported by ccmalloc,
but I think that GLOBAL_CONSTANTS_TABLE is missing too.

vesselin

diff -ruN php5-200308250130.orig/Zend/zend.c php5-200308250130/Zend/zend.c
--- php5-200308250130.orig/Zend/zend.c	2003-08-24 14:07:14.000000000 +0000
+++ php5-200308250130/Zend/zend.c	2003-08-25 08:13:52.000000000 +0000
@@ -685,7 +685,9 @@
 	zend_destroy_rsrc_list_dtors();
 
 	zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
+	free(GLOBAL_FUNCTION_TABLE);
 	zend_hash_destroy(GLOBAL_CLASS_TABLE);
+	free(GLOBAL_CLASS_TABLE);
 
 	zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
 	free(GLOBAL_AUTO_GLOBALS_TABLE);
@@ -695,6 +697,7 @@
 	zend_shutdown_constants(TSRMLS_C);
 #ifdef ZTS
 	zend_hash_destroy(GLOBAL_CONSTANTS_TABLE);
+	free(GLOBAL_CONSTANTS_TABLE);
 	unregister_standard_class();
 #endif
 }
