1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 07:28:09 +02:00
Commit Graph

470 Commits

Author SHA1 Message Date
Dmitry Stogov 14fddd17df Fix arsort() crash on recursion
Fixes oss-fuzz #46315
2022-04-04 12:03:39 +03:00
Nikita Popov d0ecc83ab5 Assert hash is known when we claim it is 2021-11-17 15:47:29 +01:00
Dmitry Stogov 6729276684 Eliminate "h < ht->nNumUsed" check in zend_hash_next_index_insert_new() 2021-08-12 02:29:24 +03:00
Levi Morrison ae8647d9d3 Remove leading underscore for _zend_hash_find_known_hash (#7260)
Convert zend_hash_find_ex(..., 1) to zend_hash_find_known_hash(...)
Convert zend_hash_find_ex(..., 0) to zend_hash_find(...)

Also add serializable changes to UPGRADING.INTERNALS summary
2021-07-20 17:07:17 -06:00
Patrick Allaert aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Nikita Popov 07da2e3f28 Add comment for specialization in zend_hash_real_init_packed_ex()
As the seemingly reundant code may be confusing. Closes GH-6988.
2021-05-26 11:52:36 +02:00
George Peter Banyard aca6aefd85 Remove 'register' type qualifier (#6980)
The compiler should be smart enough to optimize this on its own
2021-05-14 13:38:01 +01:00
Josh Soref 462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
Dmitry Stogov e86bea8d45 Extend ZEND_HASH_FILL_* API with ZEND_HASH_FILL_GROW and use it to optimize get_declared_classes() 2021-04-06 16:18:47 +03:00
Dmitry Stogov 340013ad01 Add zend_hash_lookup() and zend_hash_index_lookup() functions.
Thet search for an element with given key/index and add an empty one (NULL), if no found.
2021-03-19 22:36:24 +03:00
Dmitry Stogov 89c61186ff micro-optimization 2021-03-19 16:57:42 +03:00
Nikita Popov 26c3fa2759 Merge branch 'PHP-8.0'
* PHP-8.0:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:51 +01:00
Nikita Popov 5875bf754e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:29 +01:00
Nikita Popov 2c508c4d40 Always remove HT iterators, even for uninit HT
Fixes oss-fuzz #31423.
2021-03-01 16:22:11 +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 66ecee6243 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Detect self-addition of array more accurately
  Deindirect source elements in zend_hash_merge
2020-10-12 11:25:27 +02:00
Nikita Popov 5a7f9afb99 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Detect self-addition of array more accurately
  Deindirect source elements in zend_hash_merge
2020-10-12 11:24:59 +02:00
Nikita Popov e304468e57 Deindirect source elements in zend_hash_merge
If the RHS has INDIRECT elements, we do not those to be added to
the LHS verbatim. As we're using UPDATE_INDIRECT, we might even
create a nested INDIRECT that way.

This is a side-quest of oss-fuzz #26245.
2020-10-12 11:24:27 +02:00
Nikita Popov da0663a337 Add GC_TRY_ADDREF macro
That adds a ref if not immutable. Also audit uses of GC_IMMUTABLE
to either use GC_TRY_ADDREF or GC_TRY_PROTECT_RECURSION.
2020-09-15 11:41:09 +02:00
George Peter Banyard fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
Nikita Popov ecf368b8f2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79792
2020-07-07 12:00:34 +02:00
Nikita Popov 48a247178e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79792
2020-07-07 11:59:40 +02:00
Nikita Popov 64931fd3c4 Fixed bug #79792
We need to remove the iterators even if the array is empty (we
will not create one if the first place, but the array may become
empty after the fact).
2020-07-07 11:58:25 +02:00
Nikita Popov e12b9df05d Make sorting stable
Make user-exposed sorts stable, by storing the position of elements
in the original array, and using those positions as a fallback
comparison criterion. The base sort is still hybrid q/insert.

The use of true/false comparison functions is deprecated (but still
supported) and should be replaced by -1/0/1 comparison functions,
driven by the <=> operator.

RFC: https://wiki.php.net/rfc/stable_sorting

Closes GH-5236.
2020-06-25 10:49:34 +02:00
Christoph M. Becker 92c4b06513 Use ZEND_UNREACHABLE() instead of ZEND_ASSERT(0)
Instead of marking unreachable code with `ZEND_ASSERT(0)`, we introduce
`ZEND_UNREACHABLE()`, so that MSVC which does not consider `assert(0)`
to mark unreachable code does no longer trigger C4715[1] warnings in
debug builds.  This may be useful for other compilers as well.

[1] <https://docs.microsoft.com/de-de/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4715?view=vs-2019>
2020-06-16 18:39:09 +02:00
Dmitry Stogov bb3d4456ee Change GC_COLLECTABLE flag into GC_NOT_COLLECTABLE to simplify GC_MAY_LEAK() check 2020-06-15 14:26:22 +03:00
George Peter Banyard 25acc4a6b4 Fix [-Wundef] warning in Zend folder 2020-05-12 22:01:51 +02:00
Levi Morrison 90db6f2cc5 Add case insensitive find_ptr hash functions
- zend_hash_find_ptr_lc(ht, zend_string *key)
 - zend_hash_str_find_ptr_lc(ht, const char *str, size_t len)

Note that zend_hash_str_find_ptr_lc used to exist in zend_compile.c
as        zend_hash_find_ptr_lc. When exporting this I figured it
was best to use the same conventions as the rest of zend_hash.h.
2020-04-26 23:29:41 +02:00
Nikita Popov 72512418d5 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79477
2020-04-15 11:22:05 +02:00
Nikita Popov 58e6a0a602 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79477
2020-04-15 11:21:42 +02:00
Nikita Popov 79a36ff7f3 Fixed bug #79477
Make sure to deindirect properties when creating array.
2020-04-15 11:21:05 +02:00
Christoph M. Becker dcbf020f76 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79364: When copy empty array, next key is unspecified
2020-03-11 08:57:17 +01:00
Christoph M. Becker a72b261db5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79364: When copy empty array, next key is unspecified
2020-03-11 08:55:28 +01:00
Christoph M. Becker 2462f2dab1 Fix #79364: When copy empty array, next key is unspecified
We must not forget to keep the `nNextFreeElement` when duplicating
empty arrays.
2020-03-11 08:54:05 +01:00
Nikita Popov 33ef3d64da Use separate typedef for bucket comparison function
Avoid performing the same casting dance inside each sort compare
function.
2020-03-04 12:46:06 +01:00
Nikita Popov d91b166c3a Avoid shift UB for large arrays
Don't shift into the sign bit.
2020-01-28 15:34:08 +01:00
Dmitry Stogov 358a6b4c31 Reorder conditions 2019-09-12 19:43:45 +03:00
Nikita Popov 9fbf9e3e13 Merge branch 'PHP-7.4' 2019-07-04 17:13:04 +02:00
Nikita Popov 6a9127c100 Assert that HT entries using add_new APIs are really new 2019-07-04 17:12:55 +02:00
Andrey Gromov 84c4a4f17d Make zend_hash_rehash() a void function
It always succeeds.

Closes GH-4304.
2019-06-27 09:48:19 +02:00
Nikita Popov 036b0a1d4d Merge branch 'PHP-7.4' 2019-06-11 12:30:11 +02:00
Nikita Popov 51fb8dc422 Add specialized pair construction API
Closes GH-3990.
2019-06-11 12:29:55 +02:00
Nikita Popov fc1e6b3923 Merge branch 'PHP-7.4' 2019-05-07 16:22:17 +02:00
Sebastian Pop 6fad150cfd [AArch64] Use NEON to initialize zend_hash
On A72, google-benchmark measure before and after the patch:
--------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
--------------------------------------------------------------
BM_hash_init_before       43.6 ns         43.6 ns     16052937
BM_hash_init_after        27.0 ns         27.0 ns     25877296

Patch written by Ali Saidi <alisaidi@amazon.com>
and Sebastian Pop <spop@amazon.com>
2019-05-07 16:21:44 +02:00
Nikita Popov 39724f4645 Merge branch 'PHP-7.4' 2019-04-16 12:21:48 +02:00
Nikita Popov bd6ebf40b2 Don't overwrite iterator count during real init 2019-04-16 12:21:20 +02:00
Nikita Popov 2bdd212887 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-16 12:21:16 +02:00
Nikita Popov f9a755d0d2 Fix HT flags copying wrt iterator count
HT_FLAGS() includes the full flag word, including the iterator
count. When we're fully reassigning it, we need to make sure that
we either really do want to copy the iterator count (as in some
cases in array.c) or we need to mask only the actual flag byte.

Add an assert to hash_iterators_del() to make sure the iterator
count is non-zero (which is how I ran into this) and make sure that
the iterator count is correctly preserved during array splicing.
2019-04-16 12:14:45 +02:00
Nikita Popov 772a158d7a Merge branch 'PHP-7.4' 2019-04-16 10:40:01 +02:00
Nikita Popov 32fb2d9343 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-16 10:39:48 +02:00