]> granicus.if.org Git - php/commitdiff
- Fix memleak, Zend's built-in functions get copied before we copy all
authorMarcus Boerger <helly@php.net>
Sun, 10 Aug 2008 21:52:05 +0000 (21:52 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 10 Aug 2008 21:52:05 +0000 (21:52 +0000)
  functions, thus ending up in the name and param definitions copied twice
  because zend_register_funciton already copies them.
- Also Be able to deallocate Zend's built-in functions and do so when
  appropriate.
- After unregistering Zend's built-in functions only dl() is left and that
  seems to be fine.

Zend/zend.c
Zend/zend.h
Zend/zend_builtin_functions.c
Zend/zend_builtin_functions.h
main/main.c

index b232bd32bed5bee015ff23439aaa7c05001ac2a9..9cde763a8206c0a0aafd4eb9e494097ace5f8549 100644 (file)
@@ -1045,7 +1045,7 @@ static void unicode_globals_dtor(zend_unicode_globals *unicode_globals TSRMLS_DC
 
 void zend_init_opcodes_handlers(void);
 
-int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions) /* {{{ */
+int zend_startup(zend_utility_functions *utility_functions, char **extensions) /* {{{ */
 {
 #ifdef ZTS
        zend_compiler_globals *compiler_globals;
@@ -1170,10 +1170,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        zend_init_exception_op(TSRMLS_C);
 #endif
 
-       if (start_builtin_functions) {
-               zend_startup_builtin_functions(TSRMLS_C);
-       }
-
        zend_ini_startup(TSRMLS_C);
 
 #ifdef ZTS
@@ -1209,6 +1205,7 @@ void zend_register_standard_ini_entries(TSRMLS_D) /* {{{ */
                ucnv_close(UG(runtime_encoding_conv));
                UG(runtime_encoding_conv) = old_runtime_encoding_conv;
        }
+       zend_startup_builtin_functions(TSRMLS_C);
 }
 /* }}} */
 
@@ -1248,6 +1245,7 @@ void zend_shutdown(TSRMLS_D) /* {{{ */
 #endif
        zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
        zend_hash_graceful_reverse_destroy(&module_registry);
+       zend_shutdown_builtin_functions(TSRMLS_C);
 
        zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
        zend_hash_destroy(GLOBAL_CLASS_TABLE);
index c890cb240b44ced0f772828802e7ebe7dbdda35d..949fea3916bf49e9fb80274daf757508eedf78d9 100644 (file)
@@ -572,7 +572,7 @@ typedef int (*zend_write_func_t)(const char *str, uint str_length);
 /* default engine string type */
 #define ZEND_STR_TYPE (UG(unicode) ? IS_UNICODE : IS_STRING)
 
-int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions);
+int zend_startup(zend_utility_functions *utility_functions, char **extensions);
 void zend_shutdown(TSRMLS_D);
 void zend_register_standard_ini_entries(TSRMLS_D);
 void zend_post_startup(TSRMLS_D);
index 715219a54ca07dbe99a46923dcc8361f4d6a01e4..bf1caf8a98776710aa8dbd4b4f805e8766e7c349 100644 (file)
@@ -416,6 +416,12 @@ int zend_startup_builtin_functions(TSRMLS_D) /* {{{ */
 }
 /* }}} */
 
+void zend_shutdown_builtin_functions(TSRMLS_D) /* {{{ */
+{
+       zend_unregister_functions(builtin_functions, -1, NULL TSRMLS_CC);
+}
+/* }}} */
+
 /* {{{ proto string zend_version(void) U
    Get the version of the Zend Engine */
 ZEND_FUNCTION(zend_version)
index deb313eeb2a4e585d5fc2d22ffb874346c9eb16f..9729f42095e8064b97e845bc2a8f2edeb8d27bc9 100644 (file)
@@ -23,6 +23,7 @@
 #define ZEND_BUILTIN_FUNCTIONS_H
 
 int zend_startup_builtin_functions(TSRMLS_D);
+int zend_shutdown_builtin_functions(TSRMLS_D);
 
 BEGIN_EXTERN_C()
 ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int provide_object TSRMLS_DC);
index 1ba177eddf325c703493c546805cc92deae5f22b..859a4655dc605528ab5af6e86052689dc8572286 100644 (file)
@@ -1838,7 +1838,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        zuf.vspprintf_function = vspprintf;
        zuf.getenv_function = sapi_getenv;
        zuf.resolve_path_function = php_resolve_path_for_zend;
-       zend_startup(&zuf, NULL, 1);
+       zend_startup(&zuf, NULL);
 
 #ifdef ZTS
        executor_globals = ts_resource(executor_globals_id);