summaryrefslogtreecommitdiff
path: root/ext/standard/math.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-12-23 18:16:52 +0100
committerAnatol Belski <ab@php.net>2015-12-23 18:26:55 +0100
commit95454c448bdd540adc32e780f0b4ea7bfd80cb28 (patch)
treecab488a08362e5fdd2f4474c72d9815227871e4b /ext/standard/math.c
parentdbda61b19bb074849cc2b6a96314f3ce97cfd17b (diff)
downloadphp-git-95454c448bdd540adc32e780f0b4ea7bfd80cb28.tar.gz
Bug #71201 round() segfault on 64-bit builds
Diffstat (limited to 'ext/standard/math.c')
-rw-r--r--ext/standard/math.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 6059f3dd9b..6203626a55 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -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);