From: Nikita Popov Date: Fri, 23 May 2014 11:15:08 +0000 (+0200) Subject: Remove UB in signed printing macro X-Git-Tag: POST_PHPNG_MERGE~304 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c838f6c5b9a1daf32d24f9acced793d7cb9647da;p=php Remove UB in signed printing macro Signed->unsigned conversion and unsigned negation are well-defined (unlike signed negation for LONG_MIN.) --- diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index f03e05b3ad..d61fbc2647 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -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)); \