Skip to content
Closed
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
6 changes: 4 additions & 2 deletions ext/spl/spl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,14 @@ static bool spl_array_has_dimension_ex(bool check_inherited, zend_object *object
}
}

/* empty() check the value is not falsy, isset() only check it is not null */
bool result = check_empty ? zend_is_true(value) : Z_TYPE_P(value) != IS_NULL;

if (value == &rv) {
zval_ptr_dtor(&rv);
}

/* empty() check the value is not falsy, isset() only check it is not null */
return check_empty ? zend_is_true(value) : Z_TYPE_P(value) != IS_NULL;
return result;
} /* }}} */

static int spl_array_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */
Expand Down
20 changes: 20 additions & 0 deletions ext/spl/tests/gh18018.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
GH-18018 (RC1 data returned from offsetGet causes UAF in ArrayObject)
--FILE--
<?php
class Crap extends ArrayObject
{
public function offsetGet($offset): mixed
{
return [random_int(1,1)];
}
}

$values = ['qux' => 1];

$object = new Crap($values);

var_dump(empty($object['qux']));
?>
--EXPECT--
bool(false)
Loading