From cd67ec8ed65cd419d155c21ba6dd39306c543a42 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Mon, 7 Sep 2015 00:38:38 +0000 Subject: [PATCH] ICU-11765 fix u_charsToUChars() string length and make its destination buffer large enough X-SVN-Rev: 37894 --- icu4c/source/test/cintltst/currtest.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/icu4c/source/test/cintltst/currtest.c b/icu4c/source/test/cintltst/currtest.c index 0eba0f187af..330d5520f80 100644 --- a/icu4c/source/test/cintltst/currtest.c +++ b/icu4c/source/test/cintltst/currtest.c @@ -244,12 +244,13 @@ static const NumCodeTestEntry NUMCODE_TESTDATA[] = { }; static void TestNumericCode(void) { - UChar code[4]; + UChar code[8]; // at least one longer than the longest alphaCode int32_t i; int32_t numCode; for (i = 0; NUMCODE_TESTDATA[i].alphaCode; i++) { - u_charsToUChars(NUMCODE_TESTDATA[i].alphaCode, code, sizeof(code)/sizeof(code[0])); + int32_t length = uprv_strlen(NUMCODE_TESTDATA[i].alphaCode); + u_charsToUChars(NUMCODE_TESTDATA[i].alphaCode, code, length + 1); // +1 includes the NUL numCode = ucurr_getNumericCode(code); if (numCode != NUMCODE_TESTDATA[i].numericCode) { log_data_err("Error: ucurr_getNumericCode returned %d for currency %s, expected - %d\n",