Fix #79364: When copy empty array, next key is unspecified#5253
Fix #79364: When copy empty array, next key is unspecified#5253cmb69 wants to merge 1 commit intophp:PHP-7.3from
Conversation
We must not forget to keep the `nNextFreeElement` when duplicating empty arrays.
|
I believe the correct behavior is the other way around: We should always reset the next free element when copying arrays. |
|
Or maybe not, who knows. Is there a benefit for going in one direction or the other? |
nikic
left a comment
There was a problem hiding this comment.
As we do copy the internal array pointer, which is a very similar bit of hidden state, I guess this is okay.
For master, we should maybe investigate how expensive it is to have an "always correct" next free element...
|
Thanks! Applied as 2462f2d.
Well, I think the current behavior (modulo this bug, which is about a very special case, namely empty arrays with |
|
@cmb69 Sorry, I was a bit unclear there: What I meant by "always correct" is to adjust the next free element on unset, so it actually stays the next free element, without holes. |
|
Ah, thanks! I agree that this is something worth to be investigated. :) |
We must not forget to keep the
nNextFreeElementwhen duplicatingempty arrays.