1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 15:38:49 +02:00
Commit Graph

2607 Commits

Author SHA1 Message Date
Christoph M. Becker 9800845d43 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:55:40 +02:00
Christoph M. Becker e73cc7aea9 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:55:11 +02:00
Christoph M. Becker 6154aa652d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:52:58 +02:00
Christoph M. Becker 2d6684091f Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
We address the `::setSize(0)` case by setting `array->element = NULL`
and `array->size = 0` before we destroy the elements.

Co-authored-by: Tyson Andre <tyson.andre@uwaterloo.ca>

Closes GH-7503.
2021-09-28 15:48:53 +02:00
Nikita Popov f13c22fbfb Remove unnecessary zend_user_iterator use in spl_array
We no longer use any functionality of zend_user_iterator here.
2021-09-24 15:12:55 +02:00
Nikita Popov 15bbf6f337 Automatically determine whether to reuse get_iterator()
Same as with the IteratorAggregate case, allow reusing get_iterator
if none of the Iterator methods are overridden. Drop the
REUSE_GET_ITERATOR flag that previously allowed ArrayIterator to
opt-in to unconditional get_iterator reuse, and drop the override
handling it did, in favor of the automated approach.
2021-09-24 15:11:26 +02:00
Nikita Popov d0dbf7296b Initialize iterator_funcs_ptr upfront
Same as we do for the IteratorAggregate case, initialize the
Iterator methods upfront. This is preparation for an upcoming
change to automatically determine whether get_iterator can be
reused in a child class, in the same way we already do for
IteratorAggregate.
2021-09-24 14:57:13 +02:00
Nikita Popov 088e547802 Fix FileSystemIterator without SKIP_DOTS
There were two separate bugs here:
 * The get_iterator implementation did not match the Iterator
   implementation. In particular, get_iterator did not respect
   SKIP_DOTS.
 * The constructor did not honor an explicitly omitted SKIP_DOTS
   flag. It could still be unset through setFlags() though.
2021-09-24 14:40:46 +02:00
Nikita Popov fbbbb4876b Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix leak when iterating uninitialized RecursiveIteratorIterator
2021-09-24 13:18:11 +02:00
Nikita Popov eac65680ab Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix leak when iterating uninitialized RecursiveIteratorIterator
2021-09-24 13:18:00 +02:00
Nikita Popov 3adbafeef7 Fix leak when iterating uninitialized RecursiveIteratorIterator 2021-09-24 13:17:34 +02:00
Nikita Popov 4448934820 Don't mark SplFixedArray as REUSE_GET_ITERATOR
This flag only has an effect (or use) for Iterators, not for
IteratorAggregates. Removing the confusing flag.
2021-09-24 12:40:46 +02:00
Nikita Popov 3fd252e374 Remove unnecessary zend_user_iterator use in spl_dllist_it
We don't make use of any functionality of zend_user_iterator,
a plain zend_object_iterator will do.
2021-09-24 12:18:21 +02:00
Nikita Popov 644710eef0 Remove unused flags from spl_heap_it
Which makes it equivalent to just zend_user_iterator, so drop the
wrapper entirely.
2021-09-24 12:02:25 +02:00
George Peter Banyard a51869a202 Fix test by using a format specifier for resource to int conversion
Surprised this worked for so long
2021-09-17 23:05:35 +01:00
Tyson Andre 082c5b8327 Merge branch 'PHP-8.1' 2021-09-13 21:32:21 -04:00
Tyson Andre 27976d7dc7 Merge branch 'PHP-8.0' into PHP-8.1 2021-09-13 21:18:56 -04:00
Tyson Andre 753645a6f8 Merge remote-tracking branch 'origin/PHP-7.4' into PHP-8.0 2021-09-13 21:00:53 -04:00
Tyson Andre b053192a03 Fix #81429: Handle resizing in SplFixedArray::offsetSet (#7487)
offsetSet did not account for the fact that the array may no longer exist after
the field is overwritten. This fixes that.

Add test of resizing both to the empty array and a smaller array - there should
be no valgrind warnings with a proper fix.

Alternate approach to #7486 (described in https://bugs.php.net/bug.php?id=81429)
2021-09-13 20:59:06 -04:00
Máté Kocsis a1a8e9032c Remove unnecessary PHP_FUNCTION() declarations (#7472) 2021-09-07 10:04:00 +02:00
Nikita Popov 768265cd22 Fix some more CLEAN sections 2021-09-06 17:03:35 +02:00
Nikita Popov 2ffa70b97c Slightly clean up is_callable implementation
And adjust an error message to line up with the error message
used for $callable() in zend_execute.c.
2021-09-02 10:37:13 +02:00
Nikita Popov 5b2ddf5a17 Export zend_use_resource_as_offset()
Use a common implementation to generate this error message, as
we do so in quite a few places dealing with array keys.
2021-08-31 10:58:01 +02:00
Máté Kocsis 8e6e9838b0 Add support for generating MAY_BE_ARRAY_OF_REF func info flag (#7416) 2021-08-30 13:50:34 +02:00
Máté Kocsis bdfe0ab505 Generate Zend, ext/spl and ext/json optimizer func info from stubs
Closes GH-7397
2021-08-25 10:37:27 +02:00
Kamil Tekiela 6b1337b736 Fix typo [no-ci] 2021-07-30 13:58:28 +01:00
Andrii Dembitskyi d7b77a40e6 Fix SplFileObject::fseek() method description (#7321) 2021-07-30 13:50:43 +01:00
Nikita Popov 6d505d4445 Add RETURN/RETVAL_COPY_DEREF() macros
These were missing from the set...

I think quite a few of these usages don't actually need the DEREF,
but I've just kept things as is for now.
2021-07-22 09:44:19 +02:00
Máté Kocsis 23b1c4a982 Migrate to PHP-Parser 4.12.0 and regenerate some arginfos 2021-07-22 09:40:16 +02:00
Máté Kocsis 7a9a37d909 Actually, abstract methods don't have a body 2021-07-20 01:00:10 +02:00
Máté Kocsis fc0d8983d3 Fix some smaller formatting inconsistencies in stubs 2021-07-20 00:52:26 +02:00
Nikita Popov 814a932734 Add ZEND_ACC_NOT_SERIALIZABLE flag
This prevents serialization and unserialization of a class and its
children in a way that does not depend on the zend_class_serialize_deny
and zend_class_unserialize_deny handlers that will be going away
in PHP 9 together with the Serializable interface.

In stubs, `@not-serializable` can be used to set this flag.

This patch only uses the new flag for a handful of Zend classes,
converting the remainder is left for later.

Closes GH-7249.
Fixes bug #81111.
2021-07-19 15:59:11 +02:00
Máté Kocsis 75a678a7e3 Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00
Máté Kocsis b3e0888129 Declare tentative return types in ext/spl - part 3 (#7239) 2021-07-16 12:09:05 +02:00
Máté Kocsis fae7cec6fb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix some more ext/spl return types
2021-07-15 16:41:52 +02:00
Máté Kocsis fc6656e0ac Fix some more ext/spl return types
Closes GH-7242
2021-07-15 16:40:29 +02:00
Nikita Popov c2b29308ff Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix RecursiveIteratorIterator segfault for invalid aggregate
2021-07-15 13:11:39 +02:00
Nikita Popov b9ae73eee9 Fix RecursiveIteratorIterator segfault for invalid aggregate
The code was assuming that the returned value is an object.
Reuse the logic from IteratorIterator.
2021-07-15 13:11:28 +02:00
Nikita Popov f556a30b92 Narrow ArrayIterator::key() return type
This can only return string|int|null, not any key type.
2021-07-15 11:03:50 +02:00
Nikita Popov 11f62c989e Revert "IteratorIterator::getInnerIterator() can't return null"
This reverts commit c252420d08.

This (currently) does not hold for invalid AppendIterators,
revert for now.
2021-07-15 11:01:28 +02:00
Nikita Popov c252420d08 IteratorIterator::getInnerIterator() can't return null
If ther IteratorIterator is initialized (which we check), then
zobject cannot be undef and the return value cannot be null.
2021-07-15 10:42:34 +02:00
Máté Kocsis 6d805ed275 Declare tentative return types for ext/spl - part 2
Closes GH-7235
2021-07-14 15:19:51 +02:00
Nikita Popov 42cb5b5fa8 Throw from MultipleIterator::key/current() for invalid iterator
Calling current()/key() on an invalid iterator is an error
condition. Throw instead of returning false.
2021-07-14 12:40:45 +02:00
Máté Kocsis 1bd779c231 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix some return types in ext/spl
2021-07-14 12:38:17 +02:00
Nikita Popov 58f3f751ca Throw from SplObjectStorage::current() for invalid iterator
Accessing key()/current() on an invalid iterator is an error
condition. Throw instead of returning null.
2021-07-14 12:34:39 +02:00
Máté Kocsis d618ed0a2d Fix some return types in ext/spl
Closes GH-7237
2021-07-14 12:33:14 +02:00
Máté Kocsis c6357b804e Declare tentative return types for ext/spl - part 1 (#7115) 2021-07-13 13:04:45 +02:00
Máté Kocsis 0192fd20cc Merge branch 'PHP-8.0' 2021-07-12 10:32:07 +02:00
Máté Kocsis 80e5ad5a29 Various ext/spl stub fixes
Closes GH-7215
2021-07-12 10:27:05 +02:00
Nikita Popov 8a67dfd16b Ensure correct return type from SplFileObject::getCurrentLine()
This is necessary to maintain return type consistency once
tentative return types are added.
2021-07-06 14:32:39 +02:00