Skip to content

Commit 37bc8f9

Browse files
reset global pointers to prevent use-after-free
1 parent 8690d52 commit 37bc8f9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ ZEND_EXT_API void zend_jit_status(zval *ret)
820820
add_assoc_long(&stats, "kind", JIT_G(trigger));
821821
add_assoc_long(&stats, "opt_level", JIT_G(opt_level));
822822
add_assoc_long(&stats, "opt_flags", JIT_G(opt_flags));
823-
if (dasm_buf) {
823+
if (dasm_buf && dasm_end && dasm_ptr) {
824824
add_assoc_long(&stats, "buffer_size", (char*)dasm_end - (char*)dasm_buf);
825825
add_assoc_long(&stats, "buffer_free", (char*)dasm_end - (char*)*dasm_ptr);
826826
} else {
@@ -5078,6 +5078,12 @@ ZEND_EXT_API void zend_jit_shutdown(void)
50785078
#else
50795079
zend_jit_trace_free_caches(&jit_globals);
50805080
#endif
5081+
5082+
// Reset global pointers to prevent use-after-free in Apache reload
5083+
dasm_ptr = NULL;
5084+
dasm_buf = NULL;
5085+
dasm_end = NULL;
5086+
dasm_size = 0;
50815087
}
50825088

50835089
static void zend_jit_reset_counters(void)

0 commit comments

Comments
 (0)