From 28ce1b04ef2b818ccc64df656865ec20af2f35fc Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 17 Oct 2025 22:54:04 +0200 Subject: [PATCH] intl: Fix memory leak on error in locale_filter_matches() Closes GH-20207. --- NEWS | 3 +++ ext/intl/locale/locale_methods.c | 1 + 2 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 057d26c7d52e3..96dd99d8da89b 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,9 @@ PHP NEWS . Fixed bug GH-20070 (Return type violation in imagefilter when an invalid filter is provided). (Girgias) +- Intl: + . Fix memory leak on error in locale_filter_matches(). (nielsdos) + - LibXML: . Fix not thread safe schema/relaxng calls. (SpencerMalone, nielsdos) diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 44ae9a901a56e..cc6437625e509 100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -1301,6 +1301,7 @@ PHP_FUNCTION(locale_filter_matches) /* canonicalize lang_tag */ can_lang_tag = get_icu_value_internal( lang_tag , LOC_CANONICALIZE_TAG , &result , 0); if( result <=0) { + zend_string_release_ex( can_loc_range, false ); intl_error_set( NULL, status, "locale_filter_matches : unable to canonicalize lang_tag" , 0 ); RETURN_FALSE;