|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43201 Crash on using unitialized vals and __get/__set
Submitted: 2007-11-05 18:15 UTC Modified: 2007-11-09 09:28 UTC
From: stas at zend dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2CVS-2007-11-05 (CVS) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: stas at zend dot com
New email:
PHP Version: OS:


 [2007-11-05 18:15 UTC] stas at zend dot com
Code modifying the result of __get (erroneously) and using undefined variables crashes, apparently because of unitialized_zval being freed. 

Reproduce code:
class Foo {
	function __get($k) {
		return null;
	function __set($k, $v) {
		$this->$k = $v;

$c = new Foo();

$c->arr[0]["k"] = 1;
$c->arr[0]["k2"] = $ref;
for($cnt=0;$cnt<6;$cnt++) {
	$ref = chop($undef);	
	$c->arr[$cnt]["k2"] = $ref;

Expected result:
No crash :)

Actual result:
On windows - crash
On Unix debug - 
php5/Zend/zend_hash.c(517) : ht=0xa533520 is being destroyed


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-05 18:20 UTC]
Shorter version:

class Foo {
	function __get($k) {
		return null;

$c = new Foo();

$c->arr[0]["k"] = 1;
$c->arr[0]["k2"] = $undef;
for($cnt=0;$cnt<6;++$cnt) {
	$c->arr[$cnt]["k2"] = chop($undef);
 [2007-11-09 09:28 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC