From: Dmitry Stogov Date: Fri, 7 Jun 2019 08:48:57 +0000 (+0300) Subject: Merge branch 'PHP-7.2' into PHP-7.3 X-Git-Tag: php-7.3.7RC1~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=972223c3428d241dd201c82c00e2d1807d2ecc68;p=php Merge branch 'PHP-7.2' into PHP-7.3 * PHP-7.2: Fixed bug #77135 (Extract with EXTR_SKIP should skip $this) --- 972223c3428d241dd201c82c00e2d1807d2ecc68 diff --cc NEWS index 107b73f73e,44644166d7..06130e0206 --- a/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) diff --cc ext/standard/array.c index f5cf77b01c,a5bcecb02c..44991cb22a --- a/ext/standard/array.c +++ b/ext/standard/array.c @@@ -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);