]> granicus.if.org Git - php/commitdiff
Perform map ptr base arithmetic through uintptr_t
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 28 Jan 2020 10:23:16 +0000 (11:23 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 28 Jan 2020 10:24:04 +0000 (11:24 +0100)
Adding an offset to the NULL pointer is undefined behavior.
Avoid this by performing arithmetic on uintptr_t instead.

Zend/zend_map_ptr.h

index 46596b5c37f2bdf682d4b667587ab8d725ced62f..c6930473cf724d5c1433468c67f17fc71411aa53 100644 (file)
@@ -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"