Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 2913cdc

Browse files
committed
Fix error handling in GetLocaleIso639LanguageTwoLetterName
1 parent 9462b4c commit 2913cdc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/corefx/System.Globalization.Native/pal_localeStringData.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ UErrorCode GetLocaleIso639LanguageTwoLetterName(const char* locale, UChar* value
7272
UErrorCode status = U_ZERO_ERROR;
7373
int32_t length = uloc_getLanguage(locale, NULL, 0, &status) + 1;
7474

75+
assert(status == U_BUFFER_OVERFLOW_ERROR);
7576
char* buf = calloc(length, sizeof(char));
7677
if (buf == NULL)
7778
{
7879
return U_MEMORY_ALLOCATION_ERROR;
7980
}
8081

82+
status = U_ZERO_ERROR;
8183
uloc_getLanguage(locale, buf, length, &status);
8284

8385
if (U_SUCCESS(status))

0 commit comments

Comments
 (0)