From a9f14af996d126ed0536d8fdf4ffad47f56b4f24 Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Thu, 5 Mar 2026 11:07:36 +0900 Subject: [PATCH] Follow-up grapheme_strrev --- ext/intl/grapheme/grapheme_string.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/intl/grapheme/grapheme_string.cpp b/ext/intl/grapheme/grapheme_string.cpp index 36c0cc0f732c..f227fede1f46 100644 --- a/ext/intl/grapheme/grapheme_string.cpp +++ b/ext/intl/grapheme/grapheme_string.cpp @@ -1181,6 +1181,9 @@ U_CFUNC PHP_FUNCTION(grapheme_strrev) current = ZSTR_LEN(string); for (end = pstr; pos != UBRK_DONE; ) { pos = ubrk_previous(bi); + if (pos == UBRK_DONE) { + break; + } end_len = current - pos; for (int32_t j = 0; j < end_len; j++) { *p++ = *(pstr + pos + j); @@ -1188,6 +1191,7 @@ U_CFUNC PHP_FUNCTION(grapheme_strrev) current = pos; } ubrk_end: + *p = '\0'; RETVAL_NEW_STR(ret); ubrk_close(bi); close: