[php-src] master: ext/standard: remove unnecessary var_hash check (#24744)

From: Date: Mon, 26 Oct 2026 20:20:02 +0000
Subject: [php-src] master: ext/standard: remove unnecessary var_hash check (#24744)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142769@lists.php.net to get a copy of this message
Author: Sjoerd Langkemper (Sjord) Committer: GitHub (web-flow) Pusher: ndossche Date: 2026-10-26T21:19:58+01:00 Commit: https://github.com/php/php-src/commit/cadc689e6b44237b866bd80eb1ba2f7c665c7b2e Raw diff: https://github.com/php/php-src/commit/cadc689e6b44237b866bd80eb1ba2f7c665c7b2e.diff 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. Changed paths: M ext/standard/var.c Diff: diff --git a/ext/standard/var.c b/ext/standard/var.c index 689594ef240a..40ce296ab081 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);

« previous php.cvs (#142769) next »