diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-02-03 12:30:42 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-02-03 12:30:42 +0100 |
commit | aba6937c0a3bbd4900060c0db34e5736f7e702c7 (patch) | |
tree | da69c51cd8261a9c91386dc70f76e1acce8623f3 /ext/intl/formatter | |
parent | c2a61c9d062e6f2a0318701c0ba4cb949daf3960 (diff) | |
parent | 57b9eca83da0525b4ba0533477cf24560ec7032f (diff) | |
download | php-git-aba6937c0a3bbd4900060c0db34e5736f7e702c7.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
Fix #79212: NumberFormatter::format() may detect wrong type
Diffstat (limited to 'ext/intl/formatter')
-rw-r--r-- | ext/intl/formatter/formatter_format.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c index 2a042ce08e..8c6a567eb2 100644 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.c @@ -48,23 +48,23 @@ PHP_FUNCTION( numfmt_format ) /* Fetch the object. */ FORMATTER_METHOD_FETCH_OBJECT; - if(type == FORMAT_TYPE_DEFAULT) { - if(Z_TYPE_P(number) == IS_STRING) { - convert_scalar_to_number_ex(number); - } - - if(Z_TYPE_P(number) == IS_LONG) { - /* take INT32 on 32-bit, int64 on 64-bit */ - type = (sizeof(zend_long) == 8)?FORMAT_TYPE_INT64:FORMAT_TYPE_INT32; - } else if(Z_TYPE_P(number) == IS_DOUBLE) { - type = FORMAT_TYPE_DOUBLE; - } else { - type = FORMAT_TYPE_INT32; - } + if(Z_TYPE_P(number) != IS_ARRAY) { + convert_scalar_to_number_ex(number); + } else { + convert_to_long(number); } - if(Z_TYPE_P(number) != IS_DOUBLE && Z_TYPE_P(number) != IS_LONG) { - convert_scalar_to_number(number ); + if(type == FORMAT_TYPE_DEFAULT) { + switch(Z_TYPE_P(number)) { + case IS_LONG: + /* take INT32 on 32-bit, int64 on 64-bit */ + type = (sizeof(zend_long) == 8)?FORMAT_TYPE_INT64:FORMAT_TYPE_INT32; + break; + case IS_DOUBLE: + type = FORMAT_TYPE_DOUBLE; + break; + EMPTY_SWITCH_DEFAULT_CASE(); + } } switch(type) { |