Skip to content

Commit 0427ef9

Browse files
committed
Avoid null arithmetic UB in EX_VAR_TO_NUM
1 parent 4786207 commit 0427ef9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Zend/zend_compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ struct _zend_execute_data {
577577
#define EX_VAR(n) ZEND_CALL_VAR(execute_data, n)
578578
#define EX_VAR_NUM(n) ZEND_CALL_VAR_NUM(execute_data, n)
579579

580-
#define EX_VAR_TO_NUM(n) ((uint32_t)(ZEND_CALL_VAR(NULL, n) - ZEND_CALL_VAR_NUM(NULL, 0)))
580+
#define EX_VAR_TO_NUM(n) ((uint32_t)((n) / sizeof(zval) - ZEND_CALL_FRAME_SLOT))
581581

582582
#define ZEND_OPLINE_TO_OFFSET(opline, target) \
583583
((char*)(target) - (char*)(opline))

0 commit comments

Comments
 (0)