Ilija Tovilo
5855bdcd6c
Fix reference returned from CallbackFilterIterator::accept()
...
Fixes oss-fuzz #58181
2023-04-20 10:18:18 +02:00
Christoph M. Becker
e004e1a93b
Merge branch 'PHP-8.0' into PHP-8.1
...
* PHP-8.0:
Fix GH-8235: iterator_count() may run indefinitely
2022-05-03 12:59:39 +02:00
Christoph M. Becker
ad7b9f4e50
Fix GH-8235: iterator_count() may run indefinitely
...
We need to prevent integer overflow to eventually stop the iteration.
A test case doesn't appear sensible for this, because even on 32bit
architectures a respective test easily runs for a few minutes.
Closes GH-8447.
2022-05-03 12:57:58 +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
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
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
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
Nikita Popov
f7b1238f13
Handle out of order destruction of RecursiveIteratorIterator
2021-07-02 17:14:00 +02:00
Nikita Popov
c2a8934b86
Fix typo in RecursiveIteratorIterator get_gc handler
2021-07-02 16:11:48 +02:00
Patrick Allaert
aff365871a
Fixed some spaces used instead of tabs
2021-06-29 11:30:26 +02:00
Nikita Popov
9c18138a71
Support GC for RecursiveIteratorIterator
...
And move its dtor_obj handler into free_obj, so that cycle leaks
get automatically detected.
2021-06-09 11:25:50 +02:00
Nikita Popov
0643301c75
Don't perform recursive get_gc call
...
On further consideration, we should be making use of the fact
that zend_object_iterator is also a zend_object here, and let
GC handle the get_gc call on it. Calling get_gc recursively like
this is generally not safe, because there is only one gc_buffer.
This also happens to be much simpler...
2021-06-09 11:15:59 +02:00
Nikita Popov
67440dd695
Null out member after releasing
...
Missed this when changing from zval -> zend_string.
2021-06-09 10:52:27 +02:00
Nikita Popov
b2cf198733
Use zend_string* for RecursiveTreeIterator prefixes
...
We don't perform any append operations on these strings, they
are fixed. Use zend_string* rather than smart_str for them.
2021-06-09 10:49:59 +02:00
Nikita Popov
6b9ffaff56
Simplify string management in RecursiveTreeIterator
...
Make use of zend_string rather than zval to clean up the
implementation.
2021-06-09 10:38:58 +02:00
Nikita Popov
d7eea8e1be
Store cached string as zend_string
...
This makes the code a bit simpler.
2021-06-09 10:15:36 +02:00
Nikita Popov
88c57df53d
Remove dual_it dtor, add more GC roots
...
Move the dual_it_free call from the dtor_obj into the free_obj
handler, allowing us to drop the dtor_obj handler entirely. This
exposes another leak in bug65387.phpt, which is addressed by
adding more GC roots in the get_gc handler.
2021-06-09 10:04:43 +02:00
Nikita Popov
15fafcd664
Expose inner dual_it iterator to GC
...
Moving the zend_iterator_dtor from dual_it_dtor to dual_it_free_storage
exposed this GC leak in an existing test. Forward the result of the
iterator get_gc to the dual_it get_gc.
2021-06-08 16:55:22 +02:00
Anatol Belski
56c16334e5
ext: Cleanup some dead assignments
...
Signed-off-by: Anatol Belski <ab@php.net>
2021-05-29 13:03:32 +02:00
George Peter Banyard
c757c61a8c
Remove unnecessary error handler replacement in SPL
...
Document why it is needed in the remaining cases
Drive-by refactoring
Closes GH-6955
2021-05-07 11:17:56 +01:00
KsaR
01b3fc03c3
Update http->https in license ( #6945 )
...
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Máté Kocsis
a92f5cbe32
Use typed property in RegexIterator
2021-04-20 14:45:42 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
...
And use it instead of comments
2021-04-07 00:46:29 +01:00
Dmitry Stogov
16649cb60d
Cache haschildren/getchildren methods of recursive iterators.
2021-03-04 17:04:55 +03:00
Máté Kocsis
4f4c031f62
Generate ext/spl class entries from stubs
...
Closes GH-6709
2021-02-18 13:01:51 +01:00
Nikita Popov
3e01f5afb1
Replace zend_bool uses with bool
...
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.
Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
2c1b5c4365
Support GC for AppendIterator
...
This also requires adding GC support for ArrayIterator internal
iterators.
2020-10-01 16:18:23 +02:00
Nikita Popov
afab9eb48c
Fix bug #65387
...
Add GC support to dual_it. This is still missing AppendIterator
support.
2020-10-01 16:12:56 +02:00
Máté Kocsis
e95fa3eb0c
Fix a few Iterator signatures
...
Closes GH-6176
2020-09-21 16:03:09 +02:00
George Peter Banyard
063fdd9422
Use ValueError instead of exceptions in SPL extension
2020-09-15 12:49:59 +02:00
George Peter Banyard
b6207338e8
Use normal error in SPL for uninitialized objects
2020-09-15 12:49:59 +02:00
George Peter Banyard
9affbef0e6
Use normal error in SPL for 'An iterator cannot be used with foreach by reference'
2020-09-15 12:49:59 +02:00
George Peter Banyard
61c299fe9c
Error promotions in SPL
...
Warning to Error promotion and a Notice to Warning promotion to align
with the behaviour specified in the Reclassify Engine Warnings RFC.
Closes GH-6072
2020-09-03 19:27:02 +02:00
Nikita Popov
0a439fa932
Merge branch 'PHP-7.4'
...
* PHP-7.4:
Add missing initialization check to RegexIterator::getRegex()
2020-08-14 10:42:14 +02:00
Nikita Popov
a0c231c0f5
Add missing initialization check to RegexIterator::getRegex()
2020-08-14 10:41:36 +02:00
Nikita Popov
7991fc2753
Accept zend_object in zend_read_property
2020-08-07 16:40:27 +02:00
Nikita Popov
dc30e1d812
Cleanup SPL instantiation code
2020-07-23 16:00:12 +02:00
Nikita Popov
e6ae1bf489
Check dual_it validity in CallbackFilterIterator::accept()
...
Avoid accessing intern->u.cbfilter null pointer, though it's
harmless here.
2020-07-22 11:31:15 +02:00
Nikita Popov
9d2af91033
Only set DIT type on successful initialization
2020-07-17 16:42:56 +02:00
Nikita Popov
954244b3cb
Convert SPL fatal error to Error exception
2020-07-17 16:06:54 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
...
Closes GH-5590
2020-07-10 21:05:28 +02:00
Nikita Popov
302933daea
Remove no_separation flag
2020-07-07 09:30:24 +02:00
Nikita Popov
df8119d3e1
Don't allow separation in CallbackFilterIterator
...
As the name might suggest, this is a *filter* iterator. If you want
to have a *map* iterator, write one, or use a generator.
2020-07-07 09:04:20 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
...
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
312201dce4
Add get_gc handle for object iterators
...
Optional handler with the same semantics as the object handler.
2020-07-01 15:17:22 +02:00
Nikita Popov
f37138d2c5
Don't use iterator_funcs_ptr if it is null
...
This avoids ubsan warnings. Alternatively we could always initialize
iterator_funcs_ptr for aggregates, instead of doing so only for
non-internal ones.
2020-06-25 10:30:40 +02:00
Nikita Popov
15846ff115
Add ZVAL_OBJ_COPY macro
...
For the common ZVAL_OBJ + GC_ADDREF pattern.
This mirrors the existing ZVAL_STR_COPY API.
2020-06-17 16:36:56 +02:00