From 86364013f996b4b99ae9d218350a3effdfd6587a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 28 Aug 2020 17:24:21 +0200 Subject: [PATCH] Avoid ubsan warning with dummy cache slot addr --- Zend/zend_compile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index b54b435ae9..18c149de54 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -62,7 +62,10 @@ typedef struct _zend_loop_var { static inline uint32_t zend_alloc_cache_slots(unsigned count) { if (count == 0) { - return (uint32_t) -1; + /* Even if no cache slots are desired, the VM handler may still want to acquire + * CACHE_ADDR() unconditionally. Returning zero makes sure that the address + * calculation is still legal and ubsan does not complain. */ + return 0; } zend_op_array *op_array = CG(active_op_array); -- 2.40.0