[php-src] PR #23589: PHP json_encode(): Check depth range before narrowing

From: Date: Sun, 06 Sep 2026 09:38:18 +0000
Subject: [php-src] PR #23589: PHP json_encode(): Check depth range before narrowing
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-38332@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/23589 Author: cuishuang json_encode() accepts $depth as a zend_long, but stores it directly in the encoder's int max_depth field. On 64-bit builds, values outside the range of int were silently narrowed before encoding. This could produce platform-dependent behavior. Check the value with ZEND_LONG_EXCEEDS_INT() before assigning it to encoder.max_depth, and throw a ValueError when it cannot be represented as an int. Values within the existing range, including depth == 0 and negative values, retain their current behavior. The regression test covers values above INT_MAX and below INT_MIN.

« previous php.git-pulls (#38332) next »