Skip to content

Commit

Permalink
[MERGE #4409 @dilijev] OS#11664710: Intl: Check hr for failure immedi…
Browse files Browse the repository at this point in the history
…ately after it is set.

Merge pull request #4409 from dilijev:intl-check-hr
  • Loading branch information
dilijev committed Dec 12, 2017
2 parents 6df4708 + 0bafc18 commit 1750fb6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,22 +679,29 @@ namespace Js
char16 normalized[ULOC_FULLNAME_CAPACITY] = { 0 };
size_t normalizedLength = 0;
hr = NormalizeLanguageTag(argString->GetSz(), argString->GetLength(), normalized, &normalizedLength);
if (FAILED(hr))
{
HandleOOMSOEHR(hr);
//If we can't normalize the tag; return undefined.
return scriptContext->GetLibrary()->GetUndefined();
}

retVal = Js::JavascriptString::NewCopyBuffer(normalized, static_cast<charcount_t>(normalizedLength), scriptContext);
#else
AutoHSTRING str;
hr = GetWindowsGlobalizationAdapter(scriptContext)->NormalizeLanguageTag(scriptContext, argString->GetSz(), &str);
DelayLoadWindowsGlobalization *wsl = scriptContext->GetThreadContext()->GetWindowsGlobalizationLibrary();
PCWSTR strBuf = wsl->WindowsGetStringRawBuffer(*str, NULL);
retVal = Js::JavascriptString::NewCopySz(strBuf, scriptContext);
#endif

if (FAILED(hr))
{
HandleOOMSOEHR(hr);
//If we can't normalize the tag; return undefined.
return scriptContext->GetLibrary()->GetUndefined();
}

DelayLoadWindowsGlobalization *wsl = scriptContext->GetThreadContext()->GetWindowsGlobalizationLibrary();
PCWSTR strBuf = wsl->WindowsGetStringRawBuffer(*str, NULL);
retVal = Js::JavascriptString::NewCopySz(strBuf, scriptContext);
#endif

return retVal;
}
Var IntlEngineInterfaceExtensionObject::EntryIntl_ResolveLocaleLookup(RecyclableObject* function, CallInfo callInfo, ...)
Expand Down

0 comments on commit 1750fb6

Please sign in to comment.