Skip to content

ext/standard: remove unnecessary var_hash check - #24744

Merged
ndossche merged 2 commits into
php:masterfrom
Sjord:var-hash-never-null
Oct 26, 2026
Merged

ndossche merged 2 commits into
php:masterfrom
Sjord:var-hash-never-null

Conversation

@Sjord

@Sjord Sjord commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

var_hash is never null. It is dereferenced elsewhere in the function, so this function would already crash if it were null. Remove null check and add assertion.

var_hash is never null. It is dereferenced elsewhere in the function, so
this function would already crash if it were null. Remove null check and
add assertion.

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange indeed

Comment thread ext/standard/var.c Outdated
}

if (var_hash && (var_already = php_add_var_hash(var_hash, struc, in_rcn_array))) {
if (var_already = php_add_var_hash(var_hash, struc, in_rcn_array)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to do this to fix the compile warn:

Suggested change
if (var_already = php_add_var_hash(var_hash, struc, in_rcn_array)) {
if ((var_already = php_add_var_hash(var_hash, struc, in_rcn_array))) {

@ndossche
ndossche merged commit cadc689 into php:master Oct 26, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants