]> granicus.if.org Git - php/commitdiff
Remove UB in signed printing macro
authorNikita Popov <nikic@php.net>
Fri, 23 May 2014 11:15:08 +0000 (13:15 +0200)
committerNikita Popov <nikic@php.net>
Fri, 23 May 2014 11:15:08 +0000 (13:15 +0200)
Signed->unsigned conversion and unsigned negation are well-defined
(unlike signed negation for LONG_MIN.)

Zend/zend_operators.h

index f03e05b3ad8476282c50d8056ba5ef896c2adf1a..d61fbc2647fa7f7284bdc8ef69c8e6e4c8ed793a 100644 (file)
@@ -979,10 +979,7 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval
 /* buf points to the END of the buffer */
 #define _zend_print_signed_to_buf(buf, num, vartype, result) do { \
        if (num < 0) { \
-               /* this might cause problems when dealing with LONG_MIN
-                  and machines which don't support long long. Works
-                  flawlessly on 32bit x86 */ \
-               _zend_print_unsigned_to_buf((buf), -(num), vartype, (result)); \
+               _zend_print_unsigned_to_buf((buf), -(vartype)(num), vartype, (result)); \
                *--(result) = '-'; \
        } else { \
                _zend_print_unsigned_to_buf((buf), (num), vartype, (result)); \