[php-src] Issue #24748: socket_set_option() crashes when the value is an object with declared properties

From: Date: Mon, 26 Oct 2026 15:22:46 +0000
Subject: [php-src] Issue #24748: socket_set_option() crashes when the value is an object with declared properties
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-253216@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/24748 Author: lacatoire ### Description The following code: ```php <?php class Linger { public $l_onoff = 1; public $l_linger = 5; } $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); var_dump(socket_set_option($socket, SOL_SOCKET, SO_LINGER, new Linger())); ``` Resulted in this output: ``` Segmentation fault ``` On 8.4.27 it is *** stack smashing detected ***: terminated, and a debug build hits zval_get_long_func: Assertion '0' failed. But I expected this output instead: ``` bool(true) ``` An array or a stdClass with the same properties gives true. SO_RCVTIMEO and SO_SNDTIMEO crash the same way (checked on a debug build). This worked before 8.3.16 and 8.4.3, when the value went through convert_to_array(). It is now read with Z_OBJPROP_P() and zend_hash_str_find(), which doesn't follow the indirect slots of declared properties. Probably the lookups need zend_hash_str_find_ind(). ### PHP Version ``` PHP 8.5.12 (cli) (built: Oct 21 2026 15:48:53) (NTS) Copyright (c) The PHP Group Built by https://github.com/docker-library/php Zend Engine v4.5.12, Copyright (c) Zend Technologies with Zend OPcache v8.5.12, Copyright (c), by Zend Technologies ``` Also PHP 8.4.27. ### Operating System Linux (official Docker image)

« previous php.bugs (#253216) next »