]> granicus.if.org Git - php/commitdiff
Fixed memory leaks
authorDmitry Stogov <dmitry@php.net>
Thu, 25 Aug 2005 13:53:38 +0000 (13:53 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 25 Aug 2005 13:53:38 +0000 (13:53 +0000)
Zend/zend.c
ext/libxml/libxml.c

index ef30b5f6f9c611571cc28832d0ac0062c32cb3e6..1f561216be2e3f238822b77b5b6d4a9a9519418b 100644 (file)
@@ -727,8 +727,24 @@ static void zend_u_function_dtor(zend_function *function)
        TSRMLS_FETCH();
 
        destroy_zend_function(function TSRMLS_CC);
-       if (function->type == ZEND_INTERNAL_FUNCTION && function->common.function_name) {
-               free(function->common.function_name);
+       if (function->type == ZEND_INTERNAL_FUNCTION) {
+               if (function->common.function_name) {
+                       free(function->common.function_name);
+               }
+               if (function->common.arg_info) {
+                       int n = function->common.num_args;
+
+                       while (n > 0) {
+                       --n;
+                         if (function->common.arg_info[n].name) {
+                               free(function->common.arg_info[n].name);
+                         }
+                         if (function->common.arg_info[n].class_name) {
+                                       free(function->common.arg_info[n].class_name);
+                               }
+                 }
+                       free(function->common.arg_info);
+               }
        }
 }
 
index 6c9318a0763b4ae74ece411ef1115f4fefe77c5f..3ccb33901e5389c1072ba5aacdcf7f80034d501c 100644 (file)
@@ -798,11 +798,14 @@ int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node expo
        export_hnd.export_func = export_function;
 
        if (zend_hash_add(&php_libxml_exports, ce->name, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL) == SUCCESS) {
+               int ret;
                UChar *uname;
 
                uname = malloc(UBYTES(ce->name_length+1));
                u_charsToUChars(ce->name, uname, ce->name_length+1);
-    return zend_u_hash_add(&php_libxml_exports, IS_UNICODE, uname, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL);
+    ret = zend_u_hash_add(&php_libxml_exports, IS_UNICODE, uname, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL);
+    free(uname);
+    return ret;
   }
   return FAILURE;
 }