Skip to content

Commit 2197a49

Browse files
committed
Fix phpGH-18145: basic_globals_ctor initialization
This resets all basic globals during ctor and just modifies the ones with a special value. It also switches to using basic_globals_p which what should be used in this context. Closes phpGH-18156
1 parent f994c2f commit 2197a49

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ PHP NEWS
5555
. Fixed bug GH-18018 (RC1 data returned from offsetGet causes UAF in
5656
ArrayObject). (nielsdos)
5757

58+
- Standard:
59+
. Fixed bug GH-18145 (php8ts crashes in php_clear_stat_cache()).
60+
(Jakub Zelenka)
61+
5862
- Treewide:
5963
. Fixed bug GH-17736 (Assertion failure zend_reference_destroy()). (nielsdos)
6064

ext/standard/basic_functions.c

+7-22
Original file line numberDiff line numberDiff line change
@@ -215,31 +215,16 @@ static void php_putenv_destructor(zval *zv) /* {{{ */
215215

216216
static void basic_globals_ctor(php_basic_globals *basic_globals_p) /* {{{ */
217217
{
218-
BG(umask) = -1;
219-
BG(user_tick_functions) = NULL;
220-
BG(user_filter_map) = NULL;
221-
BG(serialize_lock) = 0;
222-
223-
memset(&BG(serialize), 0, sizeof(BG(serialize)));
224-
memset(&BG(unserialize), 0, sizeof(BG(unserialize)));
225-
226-
memset(&BG(url_adapt_session_ex), 0, sizeof(BG(url_adapt_session_ex)));
227-
memset(&BG(url_adapt_output_ex), 0, sizeof(BG(url_adapt_output_ex)));
218+
memset(basic_globals_p, 0, sizeof(php_basic_globals));
228219

229-
BG(url_adapt_session_ex).type = 1;
230-
BG(url_adapt_output_ex).type = 0;
220+
basic_globals_p->umask = -1;
221+
basic_globals_p->url_adapt_session_ex.type = 1;
231222

232-
zend_hash_init(&BG(url_adapt_session_hosts_ht), 0, NULL, NULL, 1);
233-
zend_hash_init(&BG(url_adapt_output_hosts_ht), 0, NULL, NULL, 1);
234-
235-
#if defined(_REENTRANT)
236-
memset(&BG(mblen_state), 0, sizeof(BG(mblen_state)));
237-
#endif
238-
239-
BG(page_uid) = -1;
240-
BG(page_gid) = -1;
223+
zend_hash_init(&basic_globals_p->url_adapt_session_hosts_ht, 0, NULL, NULL, 1);
224+
zend_hash_init(&basic_globals_p->url_adapt_output_hosts_ht, 0, NULL, NULL, 1);
241225

242-
BG(syslog_device) = NULL;
226+
basic_globals_p->page_uid = -1;
227+
basic_globals_p->page_gid = -1;
243228
}
244229
/* }}} */
245230

0 commit comments

Comments
 (0)