]> granicus.if.org Git - php/commitdiff
Bug #71201 round() segfault on 64-bit builds
authorAnatol Belski <ab@php.net>
Wed, 23 Dec 2015 17:16:52 +0000 (18:16 +0100)
committerAnatol Belski <ab@php.net>
Wed, 23 Dec 2015 17:16:52 +0000 (18:16 +0100)
ext/standard/math.c

index 59bd834faf0ba9b87ff9c5161f49c9f163fe98e5..e0041731c592e838a0a88e97c52557e540f94436 100644 (file)
@@ -353,7 +353,15 @@ PHP_FUNCTION(round)
        }
 
        if (ZEND_NUM_ARGS() >= 2) {
-               places = (int) precision;
+#if SIZEOF_LONG > SIZEOF_INT
+               if (precision >= 0) {
+                       places = precision > INT_MAX ? INT_MAX : (int)precision;
+               } else {
+                       places = precision <= INT_MIN ? INT_MIN+1 : (int)precision;
+               }
+#else
+               places = precision;
+#endif
        }
        convert_scalar_to_number_ex(value);