]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.2' into PHP-7.3
authorDmitry Stogov <dmitry@zend.com>
Fri, 7 Jun 2019 08:48:57 +0000 (11:48 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 7 Jun 2019 08:48:57 +0000 (11:48 +0300)
* PHP-7.2:
  Fixed bug #77135 (Extract with EXTR_SKIP should skip $this)

1  2 
NEWS
ext/standard/array.c

diff --cc NEWS
index 107b73f73e698eb5ce54f8548befe43e2b2b6fd9,44644166d7bc00b521b351ee84b9c1939b2adced..06130e02067c60459cc57b743c1d961ef3cfa7c3
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -34,9 -22,10 +34,13 @@@ PH
    . Fixed bug #78038 (Socket_select fails when resource array contains
      references). (Nikita)
  
 +- Sodium:
 +  . Fixed bug #78114 (segfault when calling sodium_* functions from eval). (cmb)
 +
+ - Standard:
+   . Fixed bug #77135 (Extract with EXTR_SKIP should skip $this).
+     (Craig Duncan, Dmitry)
  - Zip:
    . Fixed bug #76345 (zip.h not found). (Michael Maroszek)
  
index f5cf77b01c4b05992d9b6ccbad08d9b8436dd0f4,a5bcecb02c9d2c234881812cce4380c572311e5f..44991cb22a1c3cc72fa1806c6bcc812837fbf8e7
@@@ -2054,14 -2076,10 +2055,13 @@@ prefix
                                continue;
                        }
                        if (zend_string_equals_literal(var_name, "this")) {
-                               zend_throw_error(NULL, "Cannot re-assign $this");
-                               return -1;
+                               goto prefix;
                        }
 -                      ZVAL_MAKE_REF(entry);
 -                      Z_ADDREF_P(entry);
 +                      if (Z_ISREF_P(entry)) {
 +                              Z_ADDREF_P(entry);
 +                      } else {
 +                              ZVAL_MAKE_REF_EX(entry, 2);
 +                      }
                        zend_hash_add_new(symbol_table, var_name, entry);
                        count++;
                }
@@@ -2121,11 -2145,10 +2122,10 @@@ prefix
                                continue;
                        }
                        if (zend_string_equals_literal(var_name, "this")) {
-                               zend_throw_error(NULL, "Cannot re-assign $this");
-                               return -1;
+                               goto prefix;
                        }
                        ZVAL_DEREF(entry);
 -                      if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
 +                      Z_TRY_ADDREF_P(entry);
                        zend_hash_add_new(symbol_table, var_name, entry);
                        count++;
                }
@@@ -2236,10 -2263,11 +2236,11 @@@ static zend_long php_extract_ref_prefix
  
        ZEND_HASH_FOREACH_KEY_VAL_IND(arr, num_key, var_name, entry) {
                if (var_name) {
-                       if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
+                       if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))
+                        || zend_string_equals_literal(var_name, "this")) {
                                php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1);
                                if (!php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
 -                                      zend_string_release(Z_STR(final_name));
 +                                      zval_ptr_dtor_str(&final_name);
                                        continue;
                                }
                        } else {
@@@ -2290,10 -2318,11 +2291,11 @@@ static zend_long php_extract_prefix_inv
  
        ZEND_HASH_FOREACH_KEY_VAL_IND(arr, num_key, var_name, entry) {
                if (var_name) {
-                       if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
+                       if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))
+                        || zend_string_equals_literal(var_name, "this")) {
                                php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1);
                                if (!php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
 -                                      zend_string_release(Z_STR(final_name));
 +                                      zval_ptr_dtor_str(&final_name);
                                        continue;
                                }
                        } else {
@@@ -2347,10 -2378,9 +2349,9 @@@ static zend_long php_extract_ref_skip(z
                        continue;
                }
                if (zend_string_equals_literal(var_name, "this")) {
-                       zend_throw_error(NULL, "Cannot re-assign $this");
-                       return -1;
+                       continue;
                }
 -              orig_var = zend_hash_find(symbol_table, var_name);
 +              orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
                if (orig_var) {
                        if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
                                orig_var = Z_INDIRECT_P(orig_var);
@@@ -2393,10 -2417,9 +2394,9 @@@ static zend_long php_extract_skip(zend_
                        continue;
                }
                if (zend_string_equals_literal(var_name, "this")) {
-                       zend_throw_error(NULL, "Cannot re-assign $this");
-                       return -1;
+                       continue;
                }
 -              orig_var = zend_hash_find(symbol_table, var_name);
 +              orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
                if (orig_var) {
                        if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
                                orig_var = Z_INDIRECT_P(orig_var);