From 7bc1b89eb83abc0495e30da5efda8871ff0ab81c Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Tue, 30 Apr 2024 14:08:58 -0700 Subject: [PATCH] ICU-22764 Fix gendict memory safety in toml uchars mode (cherry picked from commit 23bf38f10f146d5b637922321119926b5e60bf03) --- icu4c/source/tools/gendict/gendict.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/icu4c/source/tools/gendict/gendict.cpp b/icu4c/source/tools/gendict/gendict.cpp index 2ad508eca4ad..bf64e56e9093 100644 --- a/icu4c/source/tools/gendict/gendict.cpp +++ b/icu4c/source/tools/gendict/gendict.cpp @@ -438,7 +438,9 @@ int main(int argc, char **argv) { fprintf(f, "transform_type = \"%s\"\n", isOffset ? "offset" : "none"); fprintf(f, "transform_offset = %d\n", offset); - usrc_writeArray(f, "trie_data = [\n ", outData, isBytesTrie ? 8 : 16, outDataSize, " ", "\n]\n"); + int32_t outDataWidth = isBytesTrie ? 8 : 16; + int32_t outDataLength = isBytesTrie ? outDataSize : outDataSize / U_SIZEOF_UCHAR; + usrc_writeArray(f, "trie_data = [\n ", outData, outDataWidth, outDataLength, " ", "\n]\n"); fclose(f);