Skip to content

Commit d58e3c0

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
2 parents 4855226 + 272dc9a commit d58e3c0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Zend/zend_hash.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,11 @@ static zend_always_inline zval *_zend_hash_str_add_or_update_i(HashTable *ht, co
898898
ht->nNumOfElements++;
899899
p = ht->arData + idx;
900900
p->key = key = zend_string_init(str, len, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT);
901+
#if ZEND_RC_DEBUG
902+
if (GC_FLAGS(ht) & GC_PERSISTENT_LOCAL) {
903+
GC_MAKE_PERSISTENT_LOCAL(key);
904+
}
905+
#endif
901906
p->h = ZSTR_H(key) = h;
902907
HT_FLAGS(ht) &= ~HASH_FLAG_STATIC_KEYS;
903908
if (flag & HASH_LOOKUP) {

sapi/cli/php_cli_server.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,9 @@ static void php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */
13891389
req->query_string_len = 0;
13901390
zend_hash_init(&req->headers, 0, NULL, cli_header_value_dtor, 1);
13911391
/* No destructor is registered as the value pointed by is the same as for &req->headers */
1392+
GC_MAKE_PERSISTENT_LOCAL(&req->headers);
13921393
zend_hash_init(&req->headers_original_case, 0, NULL, NULL, 1);
1394+
GC_MAKE_PERSISTENT_LOCAL(&req->headers_original_case);
13931395
req->content = NULL;
13941396
req->content_len = 0;
13951397
req->ext = NULL;
@@ -2320,6 +2322,7 @@ static void php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_
23202322
const php_cli_server_ext_mime_type_pair *pair;
23212323

23222324
zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1);
2325+
GC_MAKE_PERSISTENT_LOCAL(&server->extension_mime_types);
23232326

23242327
for (pair = mime_type_map; pair->ext; pair++) {
23252328
size_t ext_len = strlen(pair->ext);

0 commit comments

Comments
 (0)