]> granicus.if.org Git - php/commitdiff
Fixed memory leak in prop_handlers registering
authorXinchen Hui <laruence@gmail.com>
Mon, 5 May 2014 06:04:52 +0000 (14:04 +0800)
committerXinchen Hui <laruence@gmail.com>
Mon, 5 May 2014 06:04:52 +0000 (14:04 +0800)
ext/xmlreader/php_xmlreader.c
ext/zip/php_zip.c

index 8945222e32e11df51c21143956f2c99cfbb9549c..28d098e5473bff71617d12f59ab5acda42310596 100644 (file)
@@ -448,6 +448,10 @@ static void php_xmlreader_no_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_read_in
 }
 /* }}} */
 
+static void php_xmlreader_free_prop_handler(zval *el) /* {{{ */ {
+       pefree(Z_PTR_P(el), 1);
+} /* }}} */
+
 #if LIBXML_VERSION >= 20620
 /* {{{ php_xmlreader_no_arg_string */
 static void php_xmlreader_no_arg_string(INTERNAL_FUNCTION_PARAMETERS, xmlreader_read_char_t internal_function) {
@@ -1154,6 +1158,7 @@ PHP_METHOD(xmlreader, expand)
 #endif
 }
 /* }}} */
+
 /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO(arginfo_xmlreader_close, 0)
 ZEND_END_ARG_INFO()
@@ -1253,7 +1258,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_xmlreader_expand, 0)
 ZEND_END_ARG_INFO()
 /* }}} */
 
-static const zend_function_entry xmlreader_functions[] = {
+static const zend_function_entry xmlreader_functions[] /* {{{ */ =  {
        PHP_ME(xmlreader, close, arginfo_xmlreader_close, ZEND_ACC_PUBLIC)
        PHP_ME(xmlreader, getAttribute, arginfo_xmlreader_getAttribute, ZEND_ACC_PUBLIC)
        PHP_ME(xmlreader, getAttributeNo, arginfo_xmlreader_getAttributeNo, ZEND_ACC_PUBLIC)
@@ -1285,7 +1290,7 @@ static const zend_function_entry xmlreader_functions[] = {
        PHP_ME(xmlreader, XML, arginfo_xmlreader_XML, ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
        PHP_ME(xmlreader, expand, arginfo_xmlreader_expand, ZEND_ACC_PUBLIC)
        PHP_FE_END
-};
+}; /* }}} */
 
 /* {{{ PHP_MINIT_FUNCTION
  */
@@ -1307,7 +1312,7 @@ PHP_MINIT_FUNCTION(xmlreader)
        ce.create_object = xmlreader_objects_new;
        xmlreader_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
 
-       zend_hash_init(&xmlreader_prop_handlers, 0, NULL, NULL, 1);
+       zend_hash_init(&xmlreader_prop_handlers, 0, NULL, php_xmlreader_free_prop_handler, 1);
        xmlreader_register_prop_handler(&xmlreader_prop_handlers, "attributeCount", xmlTextReaderAttributeCount, NULL, IS_LONG TSRMLS_CC);
        xmlreader_register_prop_handler(&xmlreader_prop_handlers, "baseURI", NULL, xmlTextReaderConstBaseUri, IS_STRING TSRMLS_CC);
        xmlreader_register_prop_handler(&xmlreader_prop_handlers, "depth", xmlTextReaderDepth, NULL, IS_LONG TSRMLS_CC);
index 7d967c37ad2293710605ab0e8bf76869cac614db..d97ab9e61e829a045d58f8554bea26493dd4b8fa 100644 (file)
@@ -2891,6 +2891,10 @@ static const zend_function_entry zip_class_functions[] = {
 };
 /* }}} */
 
+static void php_zip_free_prop_handler(zval *el) /* {{{ */ {
+       pefree(Z_PTR_P(el), 1);
+} /* }}} */
+
 /* {{{ PHP_MINIT_FUNCTION */
 static PHP_MINIT_FUNCTION(zip)
 {
@@ -2910,7 +2914,7 @@ static PHP_MINIT_FUNCTION(zip)
        ce.create_object = php_zip_object_new;
        zip_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
 
-       zend_hash_init(&zip_prop_handlers, 0, NULL, NULL, 1);
+       zend_hash_init(&zip_prop_handlers, 0, NULL, php_zip_free_prop_handler, 1);
        php_zip_register_prop_handler(&zip_prop_handlers, "status",    php_zip_status, NULL, NULL, IS_LONG TSRMLS_CC);
        php_zip_register_prop_handler(&zip_prop_handlers, "statusSys", php_zip_status_sys, NULL, NULL, IS_LONG TSRMLS_CC);
        php_zip_register_prop_handler(&zip_prop_handlers, "numFiles",  php_zip_get_num_files, NULL, NULL, IS_LONG TSRMLS_CC);