Skip to content

Commit b88a0d9

Browse files
committed
ICU-23272 Fix long skeleton crash while parsing
1 parent aa17de1 commit b88a0d9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

icu4c/source/i18n/unicode/numberformatter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ class U_I18N_API StringProp : public UMemory {
12321232
StringProp &operator=(StringProp &&src) noexcept;
12331233

12341234
/** @internal */
1235-
int16_t length() const {
1235+
int32_t length() const {
12361236
return fLength;
12371237
}
12381238

@@ -1250,7 +1250,7 @@ class U_I18N_API StringProp : public UMemory {
12501250

12511251
private:
12521252
char *fValue;
1253-
int16_t fLength;
1253+
int32_t fLength;
12541254
UErrorCode fError;
12551255

12561256
StringProp() : fValue(nullptr), fLength(0), fError(U_ZERO_ERROR) {

icu4c/source/test/intltest/numbertest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ class NumberSkeletonTest : public IntlTest {
305305
void perUnitInArabic();
306306
void perUnitToSkeleton();
307307
void measurementSystemOverride();
308+
void longSkeletonCrash();
308309

309310
void runIndexedTest(int32_t index, UBool exec, const char*& name, char* par = nullptr) override;
310311

icu4c/source/test/intltest/numbertest_skeletons.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void NumberSkeletonTest::runIndexedTest(int32_t index, UBool exec, const char*&
3535
TESTCASE_AUTO(perUnitInArabic);
3636
TESTCASE_AUTO(perUnitToSkeleton);
3737
TESTCASE_AUTO(measurementSystemOverride);
38+
TESTCASE_AUTO(longSkeletonCrash);
3839
TESTCASE_AUTO_END;
3940
}
4041

@@ -572,4 +573,12 @@ void NumberSkeletonTest::measurementSystemOverride() {
572573
}
573574
}
574575

576+
void NumberSkeletonTest::longSkeletonCrash() {
577+
IcuTestErrorCode status(*this, "longSkeletonCrash");
578+
UErrorCode err = U_ZERO_ERROR;
579+
UnicodeString skeleton(u"K\n%\nusage/");
580+
skeleton.padTrailing(65535, 0);
581+
UnlocalizedNumberFormatter nf = NumberFormatter::forSkeleton(skeleton, err);
582+
}
583+
575584
#endif /* #if !UCONFIG_NO_FORMATTING */

0 commit comments

Comments
 (0)