@@ -283,15 +283,11 @@ PHP_FUNCTION(round)
283
283
ZEND_PARSE_PARAMETERS_END ();
284
284
285
285
if (ZEND_NUM_ARGS () >= 2 ) {
286
- #if SIZEOF_ZEND_LONG > SIZEOF_INT
287
286
if (precision >= 0 ) {
288
- places = precision > INT_MAX ? INT_MAX : (int )precision ;
287
+ places = ZEND_LONG_INT_OVFL ( precision ) ? INT_MAX : (int )precision ;
289
288
} else {
290
- places = precision <= INT_MIN ? INT_MIN + 1 : (int )precision ;
289
+ places = ZEND_LONG_INT_UDFL ( precision ) ? INT_MIN : (int )precision ;
291
290
}
292
- #else
293
- places = precision ;
294
- #endif
295
291
}
296
292
297
293
switch (Z_TYPE_P (value )) {
@@ -1136,6 +1132,7 @@ PHP_FUNCTION(number_format)
1136
1132
{
1137
1133
double num ;
1138
1134
zend_long dec = 0 ;
1135
+ int dec_int ;
1139
1136
char * thousand_sep = NULL , * dec_point = NULL ;
1140
1137
size_t thousand_sep_len = 0 , dec_point_len = 0 ;
1141
1138
@@ -1156,7 +1153,13 @@ PHP_FUNCTION(number_format)
1156
1153
thousand_sep_len = 1 ;
1157
1154
}
1158
1155
1159
- RETURN_STR (_php_math_number_format_ex (num , (int )dec , dec_point , dec_point_len , thousand_sep , thousand_sep_len ));
1156
+ if (dec >= 0 ) {
1157
+ dec_int = ZEND_LONG_INT_OVFL (dec ) ? INT_MAX : (int )dec ;
1158
+ } else {
1159
+ dec_int = ZEND_LONG_INT_UDFL (dec ) ? INT_MIN : (int )dec ;
1160
+ }
1161
+
1162
+ RETURN_STR (_php_math_number_format_ex (num , dec_int , dec_point , dec_point_len , thousand_sep , thousand_sep_len ));
1160
1163
}
1161
1164
/* }}} */
1162
1165
0 commit comments