[php-src] PR #24630: Fixes GH-24582. Supersedes #24591, reworked along the lines suggested by @devnexen.

From: Date: Sat, 24 Oct 2026 02:44:20 +0000
Subject: [php-src] PR #24630: Fixes GH-24582. Supersedes #24591, reworked along the lines suggested by @devnexen.
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-39797@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/24630 Author: matyapiro31 zend_ffi_finalize_type() reported unsupported type specifier combinations (e.g. _Complex) with zend_ffi_parser_error(). That function ends in LONGJMP(FFI_G(bailout), ...), which jumps straight back to the SETJMP in zend_ffi_parse_decl()/zend_ffi_parse_type() and skips every cleanup in between zend_ffi_make_pointer_type() zend_ffi_make_func_type() zend_ffi_add_arg() and zend_ffi_nested_declaration() call zend_ffi_finalize_type() while holding memory that the declaration (dcl) does not own yet, so that memory was never freed: every failed FFI::cdef()/new()/type() leaked it. This no longer bails out from `zend_ffi_finalize_type(){: it reports the error, sets FFI_G(parse_failed) and continues with a placeholder type. Further parser errors are not reported again (only the first one is), and zend_ffi_parse_decl() and zend_ffi_parse_type() return FAILURE once parsing is done. The callbacks are unchanged and release their memory through their normal paths. ffi_parser.c is hand-synced with ffi.g (not regenerated). Tested on a debug ZTS build (8.4.28-dev): **ext/ffi/tests** 87 pass / 0 fail. The new test fails without the fix. Leak per failed cdef() is 0 B for all of the cases below (before: 96-312 B), including declarations with more declarations after the error, struct members and nested declarators.

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