]> granicus.if.org Git - php/commitdiff
Avoid ubsan warning with dummy cache slot addr
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 28 Aug 2020 15:24:21 +0000 (17:24 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 28 Aug 2020 15:24:21 +0000 (17:24 +0200)
Zend/zend_compile.c

index b54b435ae9f62e1ffc23ad745722e079aac019a4..18c149de546e360a8eda6785a922bfd6ca979c4a 100644 (file)
@@ -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);