com php-src: Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with opcache.protec t_memory=1):
ext/mbstring/mbstring.c
| From: | Dmitry Stogov | Date: | Thu, 17 Nov 2016 10:33:05 +0000 |
| Subject: | com php-src: Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with opcache.protec t_memory=1): ext/mbstring/mbstring.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95828@lists.php.net to get a copy of this message | ||
Commit: a67637039f742a89201d085e561e906ebf74f1ae
Author: Dmitry Stogov <dmitry@zend.com> Thu, 17 Nov 2016 13:33:05 +0300
Parents: d4b3f89c53f8812cbaede013d7e4000917cf27e1
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a67637039f742a89201d085e561e906ebf74f1ae
Log:
Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with
opcache.protect_memory=1)
Bugs:
https://bugs.php.net/26639
Changed paths:
M ext/mbstring/mbstring.c
Diff:
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 5524b41..7ae96f59 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -3766,10 +3766,12 @@ PHP_FUNCTION(mb_convert_variables)
target_hash = HASH_OF(var);
if (target_hash != NULL) {
while ((hash_entry = zend_hash_get_current_data(target_hash)) != NULL) {
- if (++target_hash->u.v.nApplyCount > 1) {
- --target_hash->u.v.nApplyCount;
- recursion_error = 1;
- goto detect_end;
+ if (!Z_IMMUTABLE_P(var)) {
+ if (++target_hash->u.v.nApplyCount > 1) {
+ --target_hash->u.v.nApplyCount;
+ recursion_error = 1;
+ goto detect_end;
+ }
}
zend_hash_move_forward(target_hash);
if (Z_TYPE_P(hash_entry) == IS_INDIRECT) {
@@ -3813,8 +3815,10 @@ detect_end:
}
if (recursion_error) {
while(stack_level-- && (var = &stack[stack_level])) {
- if (HASH_OF(var)->u.v.nApplyCount > 1) {
- HASH_OF(var)->u.v.nApplyCount--;
+ if (!Z_IMMUTABLE_P(var)) {
+ if (HASH_OF(var)->u.v.nApplyCount > 1) {
+ HASH_OF(var)->u.v.nApplyCount--;
+ }
}
}
efree(stack);
@@ -3878,10 +3882,12 @@ detect_end:
hash_entry = hash_entry_ptr;
ZVAL_DEREF(hash_entry);
if (Z_TYPE_P(hash_entry) == IS_ARRAY || Z_TYPE_P(hash_entry) == IS_OBJECT) {
- if (++(HASH_OF(hash_entry)->u.v.nApplyCount) > 1) {
- --(HASH_OF(hash_entry)->u.v.nApplyCount);
- recursion_error = 1;
- goto conv_end;
+ if (!Z_IMMUTABLE_P(hash_entry)) {
+ if (++(HASH_OF(hash_entry)->u.v.nApplyCount) > 1) {
+ --(HASH_OF(hash_entry)->u.v.nApplyCount);
+ recursion_error = 1;
+ goto conv_end;
+ }
}
if (stack_level >= stack_max) {
stack_max += PHP_MBSTR_STACK_BLOCK_SIZE;
@@ -3929,8 +3935,10 @@ conv_end:
if (recursion_error) {
while(stack_level-- && (var = &stack[stack_level])) {
- if (HASH_OF(var)->u.v.nApplyCount > 1) {
- HASH_OF(var)->u.v.nApplyCount--;
+ if (!Z_IMMUTABLE_P(var)) {
+ if (HASH_OF(var)->u.v.nApplyCount > 1) {
+ HASH_OF(var)->u.v.nApplyCount--;
+ }
}
}
efree(stack);