Commit cadc689e6b4 for php
commit cadc689e6b44237b866bd80eb1ba2f7c665c7b2e
Author: Sjoerd Langkemper <sjoerd-github@linuxonly.nl>
Date: Mon Oct 26 21:19:58 2026 +0100
ext/standard: remove unnecessary var_hash check (#24744)
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.
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 689594ef240..40ce296ab08 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -1124,6 +1124,8 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
zend_long var_already;
HashTable *myht;
+ ZEND_ASSERT(var_hash != NULL);
+
if (EG(exception)) {
return;
}
@@ -1132,7 +1134,7 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
return;
}
- 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))) {
if (var_already == -1) {
/* Reference to an object that failed to serialize, replace with null. */
smart_str_appendl(buf, "N;", 2);