diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-03-23 13:31:08 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-03-23 13:31:25 +0100 |
commit | 4576da0aa782e03667e28b6068f198a4d56c2540 (patch) | |
tree | 6a94e1809e09564359daa38f003c17d56381705b | |
parent | db08ef0d3274b239a6b9e68d71d02bb6acb71d82 (diff) | |
parent | 47c745555c9000706cd4de7fffc6e1c2f18d5521 (diff) | |
download | php-git-4576da0aa782e03667e28b6068f198a4d56c2540.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fix #79393: Null coalescing operator failing with SplFixedArray
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/spl/spl_fixedarray.c | 17 | ||||
-rw-r--r-- | ext/spl/tests/bug79393.phpt | 25 |
3 files changed, 31 insertions, 13 deletions
@@ -23,6 +23,8 @@ PHP NEWS - Spl: . Fixed bug #75673 (SplStack::unserialize() behavior). (cmb) + . Fixed bug #79393 (Null coalescing operator failing with SplFixedArray). + (cmb) - Zip: . Fixed Bug #79296 (ZipArchive::open fails on empty file). (Remi) diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index d80509f851..bceaf2be93 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -337,25 +337,16 @@ static inline zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_o } /* }}} */ +static int spl_fixedarray_object_has_dimension(zval *object, zval *offset, int check_empty); + static zval *spl_fixedarray_object_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ { spl_fixedarray_object *intern; intern = Z_SPLFIXEDARRAY_P(object); - if (type == BP_VAR_IS && intern->fptr_offset_has) { - SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(object, intern->std.ce, &intern->fptr_offset_has, "offsetexists", rv, offset); - if (UNEXPECTED(Z_ISUNDEF_P(rv))) { - zval_ptr_dtor(offset); - return NULL; - } - if (!i_zend_is_true(rv)) { - zval_ptr_dtor(offset); - zval_ptr_dtor(rv); - return &EG(uninitialized_zval); - } - zval_ptr_dtor(rv); + if (type == BP_VAR_IS && !spl_fixedarray_object_has_dimension(object, offset, 0)) { + return &EG(uninitialized_zval); } if (intern->fptr_offset_get) { diff --git a/ext/spl/tests/bug79393.phpt b/ext/spl/tests/bug79393.phpt new file mode 100644 index 0000000000..e8036c70a0 --- /dev/null +++ b/ext/spl/tests/bug79393.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #79393 (Null coalescing operator failing with SplFixedArray) +--FILE-- +<?php +$foo = new SplFixedArray(5); +$foo[0] = 'bar1'; +$foo[1] = 'bar2'; +$foo[2] = 0; +$foo[3] = false; +$foo[4] = ''; + +var_dump($foo[0] ?? null); +var_dump($foo[1] ?? null); +var_dump($foo[2] ?? null); +var_dump($foo[3] ?? null); +var_dump($foo[4] ?? null); +var_dump($foo[5] ?? null); +?> +--EXPECT-- +string(4) "bar1" +string(4) "bar2" +int(0) +bool(false) +string(0) "" +NULL |