com php-src: Fixed bug #70912 (Null ptr dereference instantiating class with invalid array property): NEWS Zend/tests/bug70912.phpt
Zend/zend_compile.c

From: Date: Fri, 13 Nov 2015 13:24:42 +0000
Subject: com php-src: Fixed bug #70912 (Null ptr dereference instantiating class with invalid array property): NEWS Zend/tests/bug70912.phpt
Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89841@lists.php.net to get a copy of this message
Commit: 25de928df77d9906c81becddca42143d19d6eedd Author: Xinchen Hui <laruence@gmail.com> Fri, 13 Nov 2015 21:01:11 +0800 Parents: a03786f7730e99e86113b826087e2271a2b001fc Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=25de928df77d9906c81becddca42143d19d6eedd Log: Fixed bug #70912 (Null ptr dereference instantiating class with invalid array property) Bugs: https://bugs.php.net/70912 Changed paths: M NEWS A Zend/tests/bug70912.phpt M Zend/zend_compile.c Diff: diff --git a/NEWS b/NEWS index 6327727..fd2e129 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2015, PHP 7.0.1 - Core: + . Fixed bug #70912 (Null ptr dereference instantiating class with invalid + array property). (Laruence) . Fixed bug #70898, #70895 (null ptr deref and segfault with crafted callable). (Anatol, Laruence) diff --git a/Zend/tests/bug70912.phpt b/Zend/tests/bug70912.phpt new file mode 100644 index 0000000..3d6d430 --- /dev/null +++ b/Zend/tests/bug70912.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #70912 (Null ptr dereference when class property is initialised to a dereferenced value) +--FILE-- +<?php +class A { + public $a=[][]; +} +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %sbug70912.php on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7044b6b..75e484f 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7381,12 +7381,15 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ case ZEND_AST_DIM: { /* constant expression should be always read context ... */ - zval *container, *dim; + if (ast->child[1] == NULL) { + zend_error_noreturn(E_COMPILE_ERROR, "Cannot use [] for reading"); + } + zend_eval_const_expr(&ast->child[0]); zend_eval_const_expr(&ast->child[1]); - if (!ast->child[0] || !ast->child[1] || ast->child[0]->kind != ZEND_AST_ZVAL || ast->child[1]->kind != ZEND_AST_ZVAL) { + if (ast->child[0]->kind != ZEND_AST_ZVAL || ast->child[1]->kind != ZEND_AST_ZVAL) { return; }

« previous php.cvs (#89841) next »