com php-src: Fixed bug #71922: NEWS Zend/tests/bug71922.phpt Zend/zend_ast.c
| From: | Nikita Popov | Date: | Tue, 29 Mar 2016 17:29:19 +0000 |
| Subject: | com php-src: Fixed bug #71922: NEWS Zend/tests/bug71922.phpt Zend/zend_ast.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91544@lists.php.net to get a copy of this message | ||
Commit: ed06d130f70691cb50bed9dc7b9db38970a9d408
Author: Nikita Popov <nikic@php.net> Tue, 29 Mar 2016 19:29:19 +0200
Parents: c7f7139985b9b6a3f95790afbe7f86f7b010aabe
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ed06d130f70691cb50bed9dc7b9db38970a9d408
Log:
Fixed bug #71922
Bugs:
https://bugs.php.net/71922
Changed paths:
M NEWS
A Zend/tests/bug71922.phpt
M Zend/zend_ast.c
Diff:
diff --git a/NEWS b/NEWS
index 4af909d..abf70d0 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PHP NEWS
(Nikita)
. Fixed bug #62059 (ArrayObject and isset are not friends). (Nikita)
. Fixed bug #71871 (Interfaces allow final and abstract functions). (Nikita)
+ . Fixed bug #71922 (Crash on assert(new class{})). (Nikita)
- Curl:
. Fixed bug #71831 (CURLOPT_NOPROXY applied as long instead of string).
diff --git a/Zend/tests/bug71922.phpt b/Zend/tests/bug71922.phpt
new file mode 100644
index 0000000..986254c
--- /dev/null
+++ b/Zend/tests/bug71922.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #71922: Crash on assert(new class{});
+--INI--
+zend.assertions=1
+assert.exception=1
+--FILE--
+<?php
+
+try {
+ assert(0 && new class {
+ } && new class(42) extends stdclass {
+ });
+} catch (AssertionError $e) {
+ echo "Assertion failure: ", $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Assertion failure: assert(0 && new class {
+} && new class(42) extends stdclass {
+})
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index 6540f82..cfcd636 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -922,6 +922,21 @@ static void zend_ast_export_zval(smart_str *str, zval *zv, int priority, int
ind
}
}
+static void zend_ast_export_class_no_header(smart_str *str, zend_ast_decl *decl, int indent) {
+ if (decl->child[0]) {
+ smart_str_appends(str, " extends ");
+ zend_ast_export_ns_name(str, decl->child[0], 0, indent);
+ }
+ if (decl->child[1]) {
+ smart_str_appends(str, " implements ");
+ zend_ast_export_ex(str, decl->child[1], 0, indent);
+ }
+ smart_str_appends(str, " {\n");
+ zend_ast_export_stmt(str, decl->child[2], indent + 1);
+ zend_ast_export_indent(str, indent);
+ smart_str_appends(str, "}");
+}
+
#define BINARY_OP(_op, _p, _pl, _pr) do { \
op = _op; \
p = _p; \
@@ -1048,18 +1063,8 @@ tail_call:
smart_str_appends(str, "class ");
}
smart_str_appendl(str, ZSTR_VAL(decl->name), ZSTR_LEN(decl->name));
- if (decl->child[0]) {
- smart_str_appends(str, " extends ");
- zend_ast_export_ns_name(str, decl->child[0], 0, indent);
- }
- if (decl->child[1]) {
- smart_str_appends(str, " implements ");
- zend_ast_export_ex(str, decl->child[1], 0, indent);
- }
- smart_str_appends(str, " {\n");
- zend_ast_export_stmt(str, decl->child[2], indent + 1);
- zend_ast_export_indent(str, indent);
- smart_str_appends(str, "}\n");
+ zend_ast_export_class_no_header(str, decl, indent);
+ smart_str_appendc(str, '\n');
break;
/* list nodes */
@@ -1344,10 +1349,20 @@ simple_list:
break;
case ZEND_AST_NEW:
smart_str_appends(str, "new ");
- zend_ast_export_ns_name(str, ast->child[0], 0, indent);
- smart_str_appendc(str, '(');
- zend_ast_export_ex(str, ast->child[1], 0, indent);
- smart_str_appendc(str, ')');
+ if (ast->child[0]->kind == ZEND_AST_CLASS) {
+ smart_str_appends(str, "class");
+ if (zend_ast_get_list(ast->child[1])->children) {
+ smart_str_appendc(str, '(');
+ zend_ast_export_ex(str, ast->child[1], 0, indent);
+ smart_str_appendc(str, ')');
+ }
+ zend_ast_export_class_no_header(str, (zend_ast_decl *) ast->child[0], indent);
+ } else {
+ zend_ast_export_ns_name(str, ast->child[0], 0, indent);
+ smart_str_appendc(str, '(');
+ zend_ast_export_ex(str, ast->child[1], 0, indent);
+ smart_str_appendc(str, ')');
+ }
break;
case ZEND_AST_INSTANCEOF:
zend_ast_export_ex(str, ast->child[0], 0, indent);