Skip to content

Commit 6d7cac7

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #28228 (NULL decimal separator is not being handled correctly).
1 parent 419bbff commit 6d7cac7

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

ext/standard/math.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,17 +1141,22 @@ PHP_FUNCTION(number_format)
11411141
}
11421142
convert_to_double_ex(num);
11431143
convert_to_long_ex(dec);
1144-
convert_to_string_ex(d_p);
1145-
convert_to_string_ex(t_s);
1146-
if (Z_STRLEN_PP(d_p)==1) {
1147-
dec_point=Z_STRVAL_PP(d_p)[0];
1148-
} else if (Z_STRLEN_PP(d_p)==0) {
1149-
dec_point=0;
1144+
1145+
if (Z_TYPE_PP(d_p) != IS_NULL) {
1146+
convert_to_string_ex(d_p);
1147+
if (Z_STRLEN_PP(d_p)==1) {
1148+
dec_point=Z_STRVAL_PP(d_p)[0];
1149+
} else if (Z_STRLEN_PP(d_p)==0) {
1150+
dec_point=0;
1151+
}
11501152
}
1151-
if (Z_STRLEN_PP(t_s)==1) {
1152-
thousand_sep=Z_STRVAL_PP(t_s)[0];
1153-
} else if(Z_STRLEN_PP(t_s)==0) {
1154-
thousand_sep=0;
1153+
if (Z_TYPE_PP(t_s) != IS_NULL) {
1154+
convert_to_string_ex(t_s);
1155+
if (Z_STRLEN_PP(t_s)==1) {
1156+
thousand_sep=Z_STRVAL_PP(t_s)[0];
1157+
} else if(Z_STRLEN_PP(t_s)==0) {
1158+
thousand_sep=0;
1159+
}
11551160
}
11561161
RETURN_STRING(_php_math_number_format(Z_DVAL_PP(num), Z_LVAL_PP(dec), dec_point, thousand_sep), 0);
11571162
break;

0 commit comments

Comments
 (0)