]> granicus.if.org Git - php/commitdiff
Use inlined version of zval_ptr_dtor() in array_map() loop
authorDmitry Stogov <dmitry@zend.com>
Thu, 29 Jun 2017 09:15:57 +0000 (12:15 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 29 Jun 2017 09:15:57 +0000 (12:15 +0300)
ext/standard/array.c

index ab34ac4a282e970c0ee2ba5cc4b567cedf1c1c55..d6ea5c481b42870fc33f3d9d8682320fa193a480 100644 (file)
@@ -6024,6 +6024,7 @@ PHP_FUNCTION(array_map)
                zend_ulong num_key;
                zend_string *str_key;
                zval *zv, arg;
+               int ret;
 
                if (Z_TYPE(arrays[0]) != IS_ARRAY) {
                        php_error_docref(NULL, E_WARNING, "Argument #%d should be an array", 2);
@@ -6046,13 +6047,11 @@ PHP_FUNCTION(array_map)
                        fci.no_separation = 0;
 
                        ZVAL_COPY(&arg, zv);
-
-                       if (zend_call_function(&fci, &fci_cache) != SUCCESS || Z_TYPE(result) == IS_UNDEF) {
-                               zval_dtor(return_value);
-                               zval_ptr_dtor(&arg);
+                       ret = zend_call_function(&fci, &fci_cache);
+                       i_zval_ptr_dtor(&arg ZEND_FILE_LINE_CC);
+                       if (ret != SUCCESS || Z_TYPE(result) == IS_UNDEF) {
+                               zend_array_destroy(Z_ARR_P(return_value));
                                RETURN_NULL();
-                       } else {
-                               zval_ptr_dtor(&arg);
                        }
                        if (str_key) {
                                zend_hash_add_new(Z_ARRVAL_P(return_value), str_key, &result);
@@ -6136,7 +6135,7 @@ PHP_FUNCTION(array_map)
 
                                if (zend_call_function(&fci, &fci_cache) != SUCCESS || Z_TYPE(result) == IS_UNDEF) {
                                        efree(array_pos);
-                                       zval_dtor(return_value);
+                                       zend_array_destroy(Z_ARR_P(return_value));
                                        for (i = 0; i < n_arrays; i++) {
                                                zval_ptr_dtor(&params[i]);
                                        }