Skip to content

Commit 0011d0d

Browse files
committed
adds failing test case for #12986
1 parent 76f24d3 commit 0011d0d

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

ext/zend_test/test.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ static zend_class_entry *zend_test_int_enum;
7373
static zend_class_entry *zend_test_magic_call;
7474
static zend_object_handlers zend_test_class_handlers;
7575

76+
static ZEND_FUNCTION(zend_test_gh12986)
77+
{
78+
ZEND_PARSE_PARAMETERS_NONE();
79+
HashTable *ht = _zend_new_array_0();
80+
HT_ALLOW_COW_VIOLATION(ht);
81+
zval value;
82+
ZVAL_LONG(&value, 1);
83+
zend_hash_next_index_insert(ht, &value);
84+
if (HT_FLAGS(ht) & HASH_FLAG_ALLOW_COW_VIOLATION) {
85+
php_printf("OK: HASH_FLAG_ALLOW_COW_VIOLATION is preserved by zend_hash_real_init_ex\n");
86+
} else {
87+
php_printf("KO: HASH_FLAG_ALLOW_COW_VIOLATION was cleared by zend_hash_real_init_ex\n");
88+
}
89+
zend_array_release(ht);
90+
}
91+
7692
static int le_throwing_resource;
7793

7894
static ZEND_FUNCTION(zend_test_func)

ext/zend_test/test.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ function zend_test_override_libxml_global_state(): void {}
246246
#endif
247247

248248
function zend_test_is_pcre_bundled(): bool {}
249+
250+
function zend_test_gh12986(): void {}
249251
}
250252

251253
namespace ZendTestNS {

ext/zend_test/test_arginfo.h

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/tests/gh12986.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-12986 (HASH_FLAG_ALLOW_COW_VIOLATION is not preserved by zend_hash_real_init_ex)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
zend_test_gh12986();
9+
10+
?>
11+
--EXPECT--
12+
OK: HASH_FLAG_ALLOW_COW_VIOLATION is preserved by zend_hash_real_init_ex

0 commit comments

Comments
 (0)