Commit Graph

409 Commits

Author SHA1 Message Date
Sammy Kaye Powers
478f119ab9 Update copyright headers to 2017 2017-01-04 11:14:55 -06:00
Tyson Andre
cdb7aafc23 Fix memory leak(null coalescing operator with Spl hash)
The SEPARATE_ARG_IF_REF macro increased the refcount of the object passed as a
key.
However, when the key did not exist in the ArrayAccess implementation,
the code returned early without trying to decrement the refcount.

Add a test of `??` succeeding+failing on a SplObjectStorage instance.
2016-11-20 15:46:13 -08:00
Anatol Belski
8c9f639a1d Revert "Fixed bug #73067 (__debugInfo crashes when throwing an exception)"
This reverts commit 2d8ab51576.
2016-10-11 11:24:08 +02:00
Xinchen Hui
2d8ab51576 Fixed bug #73067 (__debugInfo crashes when throwing an exception) 2016-09-13 10:58:57 +08:00
Xinchen Hui
e03480bfab Fixed bug #72813 (Segfault with __get returned by ref)
This should be safe change, as we don't dereference value and member
after calling setter/getter.

And compare to adding unref codes, this is much cheaper.
2016-08-12 16:24:46 +08:00
Xinchen Hui
29079f263e Strlen cleanup (additions for previous one fix)
Probably compilers will do similar optimization
2016-05-07 00:08:15 -07:00
Joe Watkins
373da7aa6f fix standard object handler for properties when type == BP_VAR_IS 2016-03-26 11:15:08 +00:00
Nikita Popov
a175aa9dca Fixed bug #71731
The read_dimension() handler in BP_VAR_IS mode will now call
offsetExists() before caling offsetGet(). This has always been a
problem, however recently the issue has been exacerbated, because
the null-coalesce operator ?? makes it visible for non-nested
array accesses.

Also fixes #69659.
2016-03-20 13:35:00 +01:00
Nikita Popov
1f6d27d3d2 Fix use of UNDEF instead of NULL in read_dimension 2016-03-20 13:33:17 +01:00
Dmitry Stogov
6039d2d914 Fixed bug #71474 (Crash because of VM stack corruption on Magento2). 2016-01-28 11:41:15 +03:00
Xinchen Hui
97a9470d97 bump year which is missed in rev 49493a2 2016-01-02 17:56:11 +08:00
Xinchen Hui
9397f52724 Fixed Bug #70967 (Weird error handling for __toString when Error is thrown) 2015-11-28 23:38:19 -08:00
Xinchen Hui
2d8d97cee2 Fixed bug #70873 (Regression on private static properties access) 2015-11-07 06:50:36 -08:00
Nikita Popov
c25e81ab7b Remove dead assignment in get_property_guard 2015-10-01 16:28:28 +02:00
Dmitry Stogov
927d68db24 Avoid reallocations 2015-09-14 23:04:27 +03:00
Xinchen Hui
66643f6192 Use efree_size 2015-09-10 16:22:07 +08:00
Xinchen Hui
7a0e68b97c Unexpected 2015-09-10 14:57:22 +08:00
Xinchen Hui
6852f9cd43 cleanup tmp_member handling 2015-09-10 14:39:25 +08:00
Dmitry Stogov
37f0c6b5cb Add myself into list of authors of the most refactored files. 2015-08-31 11:38:16 +03:00
Dmitry Stogov
25f9e25526 Fixed bug #70187 (Notice: unserialize(): Unexpected end of serialized data) 2015-08-26 03:27:05 +03:00
Dmitry Stogov
71af54e5f6 Mark error and exception functions as "cold" (Matt's idea) 2015-08-19 14:40:56 +03:00
Aaron Piotrowski
5df893ce3c Use NULL where possible for exception class
Matches usage of zend_throw_exception()/zend_throw_exception_ex().
2015-07-07 12:10:55 -05:00
Aaron Piotrowski
22c38b2ef5 Remove need to pass error level 2015-07-03 17:53:41 -05:00
Aaron Piotrowski
5a99c07ecc Enable throwing custom exceptions from errors 2015-07-03 17:53:40 -05:00
Dmitry Stogov
7aa7627172 Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
Dmitry Stogov
4bd22cf1c1 Improved zend_string API (Francois Laupretre)
Squashed commit of the following:

commit d96eab8d79
Author: Francois Laupretre <francois@tekwire.net>
Date:   Fri Jun 26 01:23:31 2015 +0200

    Use the new 'ZSTR' macros in the rest of the code.

    Does not change anything to the generated code (thanks to compat macros) but cleaner.

commit b352643910
Author: Francois Laupretre <francois@tekwire.net>
Date:   Thu Jun 25 13:45:06 2015 +0200

    Improve zend_string API

    Add missing methods
2015-06-29 16:44:54 +03:00
Dmitry Stogov
4a6e1345e2 Use COW to prevent unnecessary duplication of dynamic propertyes of stdClass (and other classes without predefined properties). 2015-06-17 12:50:16 +03:00
Nikita Popov
5d3cf577aa Make convert_to_* safe with rc>1
This only involves switching zval_dtor to zval_ptr_dtor for arrays
and making the convert_to_object for arrays a bit more generic.

All the other changes outside zend_operators.c just make use of
this new ability (use COPY instead of DUP).

What's still missing: Proper references handling. I've seen many
convert_to* calls that will break when a reference is used.

Also fixes bug #69788.
2015-06-11 23:23:57 +02:00
Dmitry Stogov
6bcf121f5b micro-optimization 2015-06-03 13:43:05 +03:00
Dmitry Stogov
ca64b41b99 Fixed zend_update_class_constants() to always resolve all constants.
Call zend_update_class_constants() only when necessary.
2015-05-21 04:13:10 +03:00
Dmitry Stogov
2a9f9860d7 Fixed bug #69534 (Cycle leaks through declared properties on internal classes) 2015-05-06 21:33:49 +03:00
Dmitry Stogov
388c2cbdbc Micro optimizations 2015-04-28 19:11:45 +03:00
Dmitry Stogov
49cf7c5d12 Don't propogate "fake" EX(called_scope) and EX(This) into each internal function.
They need quite seldom and it's cheaper to get them from corresponfing upper stack frame.
2015-04-23 12:16:37 +03:00
Dmitry Stogov
15a5f61cf4 Use fast method to check if first arguments should be passed by reference (not tested onbig endian). 2015-04-22 21:46:13 +03:00
Xinchen Hui
cefad04f0d Fixed bug #69427 (Segfault on magic method __call of private method in superclass) 2015-04-11 23:57:42 +08:00
Dmitry Stogov
5e8133f453 Squashed commit of the following:
commit 2399fc84c5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Apr 10 12:38:08 2015 +0300

    Removed useless assignment

commit 796b633817
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Apr 10 12:35:31 2015 +0300

    Fixed execution with overriden zend_execute_ex()

commit 4a9fb125aa
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Apr 10 02:02:58 2015 +0300

    Fixed executor without global registers

commit d456c30e00
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Apr 10 01:30:35 2015 +0300

    Restored original behavior for tests/classes/__call_004.phpt

commit 479646d37f
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Apr 10 00:32:17 2015 +0300

    Fixed test. We don't keep stack frame for fake function anymore.

commit 9ae61e33e2
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Apr 10 00:30:09 2015 +0300

    Use ZEND_ACC_CALL_VIA_TRAMPOLINE instead of ZEND_ACC_CALL_VIA_HANDLER. Keep ZEND_ACC_CALL_VIA_HANDLER for compatibility.

commit 0a8403a2a0
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Apr 10 00:05:43 2015 +0300

    Rename PROXY_CALL into CALL_TRAMPLINE.
    Generalize API to allow reuse EG(trampline) for other purposes.

commit 4ea0525c10
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Apr 9 23:22:25 2015 +0300

    Reuse EG(proxy_call_op) for all proxy. Move proxy related functions from zend_objects_API to zend_object_handlers.

commit 529bf737ca
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Apr 9 21:42:23 2015 +0300

    Accurate use of proxy_call

commit 5d62837d5b
Merge: 83e749f 690843f
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Apr 9 19:40:00 2015 +0300

    Merge branch 'master' into opcodefy-call

    * master:
      Fixed GOTO executor
      Fixed typo
      Changed ArrayIterator implementation using zend_hash_iterator_... API. Allowed modification of itterated ArrayObject using the same behavior as proposed in `Fix "foreach" behavior`. Removed "Array was modified outside object and internal position is no longer valid" hack.

commit 83e749ff3b
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Apr 9 19:39:10 2015 +0300

    Improved ZEND_PROXY_CALL

commit 0c829afc53
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Apr 9 15:14:49 2015 +0300

    Reverted white-space changes

commit df65144488
Merge: 5fd2f97 97756d9
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Apr 9 14:37:07 2015 +0300

    Merge branch 'opcodefy-call' of github.com:laruence/php-src into opcodefy-call

    * 'opcodefy-call' of github.com:laruence/php-src:
      Ready for PR
      Fixed static call
      Improve performance by using prealloated op_arrray
      Respect called_scope
      Support internal magical __call/__callStatic
      opcode-fy magical __callStatic
      Opcode-fy magical __call

commit 97756d9190
Author: Xinchen Hui <laruence@gmail.com>
Date:   Thu Apr 9 19:07:59 2015 +0800

    Ready for PR

commit 74f9930846
Author: Xinchen Hui <laruence@gmail.com>
Date:   Thu Apr 9 19:03:00 2015 +0800

    Fixed static call

commit ec1d9eb592
Author: Xinchen Hui <laruence@gmail.com>
Date:   Thu Apr 9 18:23:17 2015 +0800

    Improve performance by using prealloated op_arrray

commit df7fbbf949
Author: Xinchen Hui <laruence@gmail.com>
Date:   Thu Apr 9 15:10:02 2015 +0800

    Respect called_scope

commit 769d1d59fb
Author: Xinchen Hui <laruence@gmail.com>
Date:   Thu Apr 9 12:19:23 2015 +0800

    Support internal magical __call/__callStatic

commit a980fedd5b
Author: Xinchen Hui <laruence@gmail.com>
Date:   Wed Apr 8 18:35:41 2015 +0800

    opcode-fy magical __callStatic

commit 73855f7d53
Author: Xinchen Hui <laruence@gmail.com>
Date:   Wed Apr 8 14:21:55 2015 +0800

    Opcode-fy magical __call
2015-04-10 23:01:00 +03:00
Dmitry Stogov
adcf0c6052 Improved reference counting 2015-04-03 01:32:20 +03:00
Dmitry Stogov
ea09a9fa32 Convert fatal errors into EngineExceptions
Make zval_update_constant_ex(), zval_update_constant(), zend_update_class_constants() and zend_ast_evaluate() return SUCCESS or FAILURE.
2015-04-02 02:05:25 +03:00
Dmitry Stogov
acfc31c0f8 Use zend_error_noreturn() for fatal errors 2015-04-01 13:32:23 +03:00
Nikita Popov
8d00385871 Reclassify E_STRICT notices
Per RFC https://wiki.php.net/rfc/reclassify_e_strict

While reviewing this, found that there are still three E_STRICTs
left in libraries - need to discuss those.
2015-04-01 11:17:55 +02:00
Dmitry Stogov
2bf8f29d16 Converted most object handlers fatal errors into EngineExceptions 2015-04-01 00:37:59 +03:00
Dmitry Stogov
685ab95add Convert fatal errors on improper access to static properties into EngineExceptions 2015-03-31 16:35:27 +03:00
Xinchen Hui
95b4aa5293 Fixed zend_hash_append result duplicated key
actually, maybe we should precalculate before calling zend_hash_appen
when we are not sure whether the hash is caclculated(prop_info->name).

but it looks a little ugly.. (also for zend_string_copy)
2015-03-08 00:21:02 +08:00
Dmitry Stogov
9f9ffdd0a0 Use fast zend_hash_append() API 2015-03-06 19:23:54 +03:00
Xinchen Hui
f25419f8e3 Only do this in debug build 2015-02-21 22:44:51 +08:00
Dmitry Stogov
e10e151e9b Merged zend_array and HashTable into the single data structure.
Now each HashTable is also zend_array, so it's refcounted and may be a subject for Copy on Write
zend_array_dup() was changed to allocate and return HashTable, instead of taking preallocated HashTable as argument.
2015-02-13 22:20:39 +03:00
Dmitry Stogov
35aea97e42 Fixed bug #69025 (Invalid read of size 4 when calling __callStatic) 2015-02-11 17:41:21 +03:00
Dmitry Stogov
9e70d7672d Move zend_object->guards into additional slot of zend_object->properties_table[]. As result size of objects without __get/__set/__unset/__isset magic methods is reduced. 2015-02-04 15:24:13 +03:00
Xinchen Hui
1a60175e25 Fixed Magic getter bug tickled by Moodle 2015-01-31 18:12:31 +08:00
Dmitry Stogov
b46894d104 Partially revert 3477135cd1 2015-01-16 02:21:27 +03:00