From: Nikita Popov Date: Tue, 28 Jan 2020 10:23:16 +0000 (+0100) Subject: Perform map ptr base arithmetic through uintptr_t X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c59219de85a82548e7ba12399b95eae9087b3dfd;p=php Perform map ptr base arithmetic through uintptr_t Adding an offset to the NULL pointer is undefined behavior. Avoid this by performing arithmetic on uintptr_t instead. --- diff --git a/Zend/zend_map_ptr.h b/Zend/zend_map_ptr.h index 46596b5c37..c6930473cf 100644 --- a/Zend/zend_map_ptr.h +++ b/Zend/zend_map_ptr.h @@ -80,9 +80,9 @@ ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \ } while (0) # define ZEND_MAP_PTR_REAL_BASE(base) \ - ((void*)(((char*)(base)) + 1)) + ((void*)(((uintptr_t)(base)) + 1)) # define ZEND_MAP_PTR_SET_REAL_BASE(base, ptr) do { \ - base = (void*)(((char*)(ptr)) - 1); \ + base = (void*)(((uintptr_t)(ptr)) - 1); \ } while (0) #else # error "Unknown ZEND_MAP_PTR_KIND"