Skip to content

Commit ee0bf4b

Browse files
committed
Define OBJ_PROP_TO_OFFSET() using XtOffsetOf()
This avoids null pointer arithmetic UB.
1 parent ec30a3b commit ee0bf4b

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
@@ -373,7 +373,7 @@ typedef struct _zend_property_info {
373373
#define OBJ_PROP_NUM(obj, num) \
374374
(&(obj)->properties_table[(num)])
375375
#define OBJ_PROP_TO_OFFSET(num) \
376-
((uint32_t)(zend_uintptr_t)OBJ_PROP_NUM(((zend_object*)NULL), num))
376+
((uint32_t)(XtOffsetOf(zend_object, properties_table) + sizeof(zval) * (num)))
377377
#define OBJ_PROP_TO_NUM(offset) \
378378
((offset - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval))
379379

0 commit comments

Comments
 (0)