Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1915 Update property #1918

Merged
merged 1 commit into from
Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion kernels/ZendEngine3/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,9 @@ int zephir_update_property_array_append(zval *object, char *property, unsigned i
zval new_zv;
ZVAL_DUP(&new_zv, &tmp);
ZVAL_COPY_VALUE(&tmp, &new_zv);
Z_TRY_DELREF(new_zv);
if (Z_REFCOUNT(tmp) > 1) {
Z_TRY_DELREF(new_zv);
}
separated = 1;
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/properties/propertyupdate.zep
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Test\Properties;

class PropertyUpdate
{
public p1;

public function update1() {
let this->p1[] = "aaa";
}
}
28 changes: 28 additions & 0 deletions unit-tests/Extension/Properties/PropertyUpdateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the Zephir.
*
* (c) Zephir Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Extension\Properties;

use PHPUnit\Framework\TestCase;
use Test\Properties\PropertyUpdate;

class PropertyUpdateTest extends TestCase
{
public function testUpdate11()
{
// before fixed. Assertion failed: (((ht)->gc.refcount == 1) || ((ht)->u.flags & (1<<6))), function _zend_hash_index_add_or_update_i
$t = new PropertyUpdate();
$t->p1 = [111];
$t->update1();

$this->assertSame($t->p1, [111, 'aaa']);
}
}