From: Nikita Popov Date: Fri, 28 Aug 2020 15:24:21 +0000 (+0200) Subject: Avoid ubsan warning with dummy cache slot addr X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86364013f996b4b99ae9d218350a3effdfd6587a;p=php Avoid ubsan warning with dummy cache slot addr --- 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);