Skip to content

Commit 1750fb6

Browse files
committed
[MERGE #4409 @dilijev] OS#11664710: Intl: Check hr for failure immediately after it is set.
Merge pull request #4409 from dilijev:intl-check-hr
2 parents 6df4708 + 0bafc18 commit 1750fb6

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,22 +679,29 @@ namespace Js
679679
char16 normalized[ULOC_FULLNAME_CAPACITY] = { 0 };
680680
size_t normalizedLength = 0;
681681
hr = NormalizeLanguageTag(argString->GetSz(), argString->GetLength(), normalized, &normalizedLength);
682+
if (FAILED(hr))
683+
{
684+
HandleOOMSOEHR(hr);
685+
//If we can't normalize the tag; return undefined.
686+
return scriptContext->GetLibrary()->GetUndefined();
687+
}
688+
682689
retVal = Js::JavascriptString::NewCopyBuffer(normalized, static_cast<charcount_t>(normalizedLength), scriptContext);
683690
#else
684691
AutoHSTRING str;
685692
hr = GetWindowsGlobalizationAdapter(scriptContext)->NormalizeLanguageTag(scriptContext, argString->GetSz(), &str);
686-
DelayLoadWindowsGlobalization *wsl = scriptContext->GetThreadContext()->GetWindowsGlobalizationLibrary();
687-
PCWSTR strBuf = wsl->WindowsGetStringRawBuffer(*str, NULL);
688-
retVal = Js::JavascriptString::NewCopySz(strBuf, scriptContext);
689-
#endif
690-
691693
if (FAILED(hr))
692694
{
693695
HandleOOMSOEHR(hr);
694696
//If we can't normalize the tag; return undefined.
695697
return scriptContext->GetLibrary()->GetUndefined();
696698
}
697699

700+
DelayLoadWindowsGlobalization *wsl = scriptContext->GetThreadContext()->GetWindowsGlobalizationLibrary();
701+
PCWSTR strBuf = wsl->WindowsGetStringRawBuffer(*str, NULL);
702+
retVal = Js::JavascriptString::NewCopySz(strBuf, scriptContext);
703+
#endif
704+
698705
return retVal;
699706
}
700707
Var IntlEngineInterfaceExtensionObject::EntryIntl_ResolveLocaleLookup(RecyclableObject* function, CallInfo callInfo, ...)

0 commit comments

Comments
 (0)