]> 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:26:55 +0000 (18:26 +0100)
ext/standard/math.c

index 6059f3dd9bb28a7432f8b4dbb9a666343608db8c..6203626a55ad5d7428f163d1f7bc311622caf2c1 100644 (file)
@@ -390,7 +390,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);