if (resourceEntry != NULL)
{
len = PAL_GetResourceString(NULL, resourceEntry->resourceString, szBuffer, iMax);
+ if (len == 0)
+ {
+ int hr = HRESULT_FROM_GetLastError();
+
+ // Tell the caller if the buffer isn't big enough
+ if (hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) && pcwchUsed)
+ *pcwchUsed = iMax;
+
+ return hr;
+ }
}
else
{
{
// The only possible failure is that that string didn't fit the buffer. So the buffer contains
// partial string terminated by '\0'
+ // We could return ERROR_INSUFFICIENT_BUFFER, but we'll error on the side of caution here and
+ // actually show something (given that this is likely a scenario involving a bug/deployment issue)
len = iMax - 1;
}
}
return hr;
#else // !FEATURE_PAL
- LoadNativeStringResource(NATIVE_STRING_RESOURCE_TABLE(NATIVE_STRING_RESOURCE_NAME), iResourceID,
+ return LoadNativeStringResource(NATIVE_STRING_RESOURCE_TABLE(NATIVE_STRING_RESOURCE_NAME), iResourceID,
szBuffer, iMax, pcwchUsed);
- return S_OK;
#endif // !FEATURE_PAL
}
// In fatal error reporting scenarios, we may not have enough memory to
// allocate a larger buffer.
- hr = pResourceDLL->LoadString(eCategory, resourceID, GetRawUnicode(), GetRawCount()+1,&size);
+ hr = pResourceDLL->LoadString(eCategory, resourceID, GetRawUnicode(), GetRawCount()+1, &size);
if (hr != HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER))
{
if (FAILED(hr))