Skip to content

[DeepClone] Reject from_array payloads that would build an uninitialized object#631

Merged
nicolas-grekas merged 1 commit into
1.xfrom
deepclone-from-array-reject-uninitialized
Jun 10, 2026
Merged

[DeepClone] Reject from_array payloads that would build an uninitialized object#631
nicolas-grekas merged 1 commit into
1.xfrom
deepclone-from-array-reject-uninitialized

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Member
Q A
Branch? 1.x
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

Brings the polyfill in line with the extension's symfony/php-ext-deepclone#22.

deepclone_to_array() always emits a class that has __unserialize() as a negative-wakeup state replay. A crafted deepclone_from_array() payload that flags such a class for plain creation (wakeup >= 0, no replay) was reconstructed as an uninitialized object: the polyfill returned null, while the extension (before #22) built a bare shell, e.g. a BcMath\Number whose bc_num stays NULL and crashes on use.

reconstruct() now rejects such a payload with a \ValueError before building the object, using the same message as the extension. Well-formed payloads, which always carry the negative-wakeup replay for an __unserialize class, are unaffected.

…zed object

deepclone_to_array() always emits a class that has __unserialize() as a
negative-wakeup state replay. A crafted deepclone_from_array() payload
that flags such a class for plain creation (wakeup >= 0, no replay) was
reconstructed as an uninitialized object: the polyfill returned null.

reconstruct() now rejects such a payload with a \ValueError before
building the object, matching the extension (symfony/php-ext-deepclone#22).
Well-formed payloads always carry the negative-wakeup replay for an
__unserialize class, so they are unaffected.
@nicolas-grekas nicolas-grekas merged commit 6c54b2f into 1.x Jun 10, 2026
36 of 40 checks passed
@nicolas-grekas nicolas-grekas deleted the deepclone-from-array-reject-uninitialized branch June 10, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant