]> granicus.if.org Git - php/commitdiff
In php_needle_char() use well-defined double->integer cast
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 20 Jun 2019 12:09:18 +0000 (14:09 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 20 Jun 2019 14:22:10 +0000 (16:22 +0200)
...by going through zval_get_long(). Generally out of range double
casts are undefined.

ext/standard/string.c

index a40a2c36cac5f8d624da50ae09c7c3ffb5e1ce24..78b726c87ff937a568ca03821d36a00fc1674be8 100644 (file)
@@ -1814,8 +1814,6 @@ static int php_needle_char(zval *needle, char *target)
                        *target = '\1';
                        return SUCCESS;
                case IS_DOUBLE:
-                       *target = (char)(int)Z_DVAL_P(needle);
-                       return SUCCESS;
                case IS_OBJECT:
                        *target = (char) zval_get_long(needle);
                        return SUCCESS;