[php-src] Issue #19953: memory leak strdup

From: Date: Thu, 25 Sep 2025 05:46:02 +0000
Subject: [php-src] Issue #19953: memory leak strdup
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250911@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/19953 Author: YuanchengJiang ### Description The following code: ```php <?php class DummyStreamWrapper { public function stream_open(string $path, string $mode, int $options = 0, ?string &$openedPath = null): bool { return true; } } class TrampolineTest { public function __call(string $name, array $arguments) { if (!$this->wrapper) { $this->wrapper = new DummyStreamWrapper(); } return $this->wrapper->$name(...$arguments); } } stream_wrapper_register('custom', TrampolineTest::class); $fp = fopen("custom://myvar", "r+"); $resource = zend_test_create_throwing_resource(); ``` Resulted in this output: ``` ================================================================= ==1877011==ERROR: LeakSanitizer: detected memory leaks Direct leak of 14 byte(s) in 1 object(s) allocated from: #0 0x66cd54 in strdup (/home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php+0x66cd54) #1 0x68d7f09 in do_cli /home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php_cli.c:891:24 #2 0x68d40ff in main /home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php_cli.c:1362:18 #3 0x76bc3878ed8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 SUMMARY: AddressSanitizer: 14 byte(s) leaked in 1 allocation(s). ``` To reproduce: ``` ./php-src/sapi/cli/php ./test.php ``` Commit: ``` e23c6222da50a2c5828a03ad701cd3351b13590d ``` Configurations: ``` CC="clang-12" CXX="clang++-12" CFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" CXXFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" ./configure --enable-debug --enable-address-sanitizer --enable-undefined-sanitizer --enable-re2c-cgoto --enable-fpm --enable-litespeed --enable-phpdbg-debug --enable-zts --enable-bcmath --enable-calendar --enable-dba --enable-dl-test --enable-exif --enable-ftp --enable-gd --enable-gd-jis-conv --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-zend-test --with-zlib --with-bz2 --with-curl --with-enchant --with-gettext --with-gmp --with-mhash --with-ldap --with-libedit --with-readline --with-snmp --with-sodium --with-xsl --with-zip --with-mysqli --with-pdo-mysql --with-pdo-pgsql --with-pgsql --with-sqlite3 --with-pdo-sqlite --with-webp --with-jpeg --with-freetype --enable-sigchild --with-readline --with-pcre-jit --with-iconv ``` Operating System: ``` Ubuntu 20.04 Host, Docker 0599jiangyc/flowfusion:latest ``` *This report is automatically generated by [FlowFusion](https://github.com/php/flowfusion)* ### PHP Version ```plain nightly ``` ### Operating System _No response_

« previous php.bugs (#250911) next »