diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c index 938e1c612b912..7fe617451940e 100644 --- a/Zend/zend_highlight.c +++ b/Zend/zend_highlight.c @@ -186,7 +186,6 @@ ZEND_API void zend_strip(TSRMLS_D) case T_END_HEREDOC: zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); - efree(token.value.str.val); /* read the following character, either newline or ; */ if (lex_scan(&token TSRMLS_CC) != T_WHITESPACE) { zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 4de6b83e00f4e..c03c698700714 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -80,6 +80,11 @@ static int php_filter_parse_int(const char *str, unsigned int str_len, long *ret break; } + if (*str == '0' && str + 1 == end) { + /* Special cases: +0 and -0 */ + return 1; + } + /* must start with 1..9*/ if (str < end && *str >= '1' && *str <= '9') { ctx_value = ((sign)?-1:1) * ((*(str++)) - '0'); diff --git a/ext/filter/tests/filter_data.phpt b/ext/filter/tests/filter_data.phpt index 1071b3efae0ab..f83d98625c875 100644 --- a/ext/filter/tests/filter_data.phpt +++ b/ext/filter/tests/filter_data.phpt @@ -10,9 +10,13 @@ precision=14 /* Integer */ $data = "-123"; var_dump(filter_var($data, FILTER_VALIDATE_INT)); $data = "0"; var_dump(filter_var($data, FILTER_VALIDATE_INT)); +$data = "-0"; var_dump(filter_var($data, FILTER_VALIDATE_INT)); +$data = "+0"; var_dump(filter_var($data, FILTER_VALIDATE_INT)); $data = "123"; var_dump(filter_var($data, FILTER_VALIDATE_INT)); $data = -123; var_dump(filter_var($data, FILTER_VALIDATE_INT)); $data = 0; var_dump(filter_var($data, FILTER_VALIDATE_INT)); +$data = -0; var_dump(filter_var($data, FILTER_VALIDATE_INT)); +$data = +0; var_dump(filter_var($data, FILTER_VALIDATE_INT)); $data = 123; var_dump(filter_var($data, FILTER_VALIDATE_INT)); $data = ""; var_dump(filter_var($data, FILTER_VALIDATE_INT)); echo "\n"; @@ -46,9 +50,13 @@ $data = ""; var_dump(filter_var($data, FILTER_VALIDATE_BOOLEAN)); --EXPECT-- int(-123) int(0) +int(0) +int(0) int(123) int(-123) int(0) +int(0) +int(0) int(123) bool(false) diff --git a/ext/standard/tests/strings/bug63874.phpt b/ext/standard/tests/strings/bug63874.phpt new file mode 100644 index 0000000000000..066cc155df960 --- /dev/null +++ b/ext/standard/tests/strings/bug63874.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #63874 (Segfault if php_strip_whitespace has heredoc) +--FILE-- + +--EXPECT-- +