[php-src] master: ext/intl: Stop enumCharNames() when the callback throws (#23866)

From: Date: Thu, 24 Sep 2026 16:23:47 +0000
Subject: [php-src] master: ext/intl: Stop enumCharNames() when the callback throws (#23866)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141502@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Committer: GitHub (web-flow) Pusher: LamentXU123 Date: 2026-09-25T00:23:44+08:00 Commit: https://github.com/php/php-src/commit/5dfd11b1b0de6d066868ea6384d42d1aacc3b93d Raw diff: https://github.com/php/php-src/commit/5dfd11b1b0de6d066868ea6384d42d1aacc3b93d.diff ext/intl: Stop enumCharNames() when the callback throws (#23866) Changed paths: A ext/intl/uchar/tests/enumCharNames_callback_exception.phpt M ext/intl/uchar/uchar.cpp Diff: diff --git a/ext/intl/uchar/tests/enumCharNames_callback_exception.phpt b/ext/intl/uchar/tests/enumCharNames_callback_exception.phpt new file mode 100644 index 000000000000..2ebac7aac92c --- /dev/null +++ b/ext/intl/uchar/tests/enumCharNames_callback_exception.phpt @@ -0,0 +1,20 @@ +--TEST-- +IntlChar::enumCharNames() propagates callback exceptions and remains usable +--EXTENSIONS-- +intl +--FILE-- +<?php +try { + IntlChar::enumCharNames(65, 68, static function ($codepoint) { + echo $codepoint, "\n"; + throw new Exception('Stop enumeration'); + }); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} +var_dump(IntlChar::enumCharNames(65, 68, static fn() => false)); +?> +--EXPECT-- +65 +Stop enumeration +bool(true) diff --git a/ext/intl/uchar/uchar.cpp b/ext/intl/uchar/uchar.cpp index 1319ec679085..b2df5b9a05a8 100644 --- a/ext/intl/uchar/uchar.cpp +++ b/ext/intl/uchar/uchar.cpp @@ -312,7 +312,7 @@ static UBool enumCharNames_callback(enumCharNames_data *context, } zval_ptr_dtor(&retval); zval_ptr_dtor_str(&args[2]); - return 1; + return !EG(exception); } IC_METHOD(enumCharNames) { UChar32 start, limit;

« previous php.cvs (#141502) next »