fix segfault

This commit is contained in:
CismonX 2018-08-22 17:54:21 +08:00
parent 4754c5a3d6
commit d1ab22ed92
2 changed files with 8 additions and 2 deletions

View File

@ -311,6 +311,12 @@ void collection_offset_set(zval* object, zval* offset, zval* value)
{
zend_hash_update(current, Z_STR_P(offset), value);
}
else
{
ERR_BAD_KEY_TYPE();
return;
}
Z_TRY_ADDREF_P(value);
}
zval* collection_offset_get(zval* object, zval* offset, int type, zval* retval)

View File

@ -4,14 +4,14 @@ Test implementation of interface ArrayAccess.
<?php
$array = ['a' => 'b', 'c' => 'd', 'e' => ['f' => 'g']];
$collection = Collection::init($array);
$collection['a'] = 'foo';
$collection['a'] = 'foo'.strval(123);
$collection['h'] = 'bar';
unset($collection['c']);
if (empty($collection) || isset($collection['t']) || !isset($collection['e']))
echo 'Test for handlers.has_dimension failed.', PHP_EOL;
if ($collection['e']['f'] != 'g')
echo 'Test for handlers.read_dimension failed.', PHP_EOL;
if ($collection['a'] != 'foo' || $collection['h'] != 'bar')
if ($collection['a'] != 'foo'.strval(123) || $collection['h'] != 'bar')
echo 'Test for handlers.write_dimension failed.', PHP_EOL;
if (isset($collection['c']))
echo 'Test for handlers.unset_dimension failed.', PHP_EOL;