return g_pFreeObjectMethodTable;
}
-// These are arbitrary, we shouldn't ever be having confrig keys or values
+// This is arbitrary, we shouldn't ever be having config keys
// longer than these lengths.
const size_t MaxConfigKeyLength = 255;
-const size_t MaxConfigValueLength = 255;
bool GCToEEInterface::GetBooleanConfigValue(const char* key, bool* value)
{
return false;
}
+ int charCount = WideCharToMultiByte(CP_ACP, 0, out, -1 /* out is null-terminated */, NULL, 0, nullptr, nullptr);
+ if (charCount == 0)
+ {
+ // this should only happen if the config subsystem gives us a string that's not valid
+ // unicode.
+ CLRConfig::FreeConfigString(out);
+ return false;
+ }
+
// not allocated on the stack since it escapes this function
- AStringHolder configResult = new (nothrow) char[MaxConfigValueLength];
+ AStringHolder configResult = new (nothrow) char[charCount];
if (!configResult)
{
CLRConfig::FreeConfigString(out);
}
if (WideCharToMultiByte(CP_ACP, 0, out, -1 /* out is null-terminated */,
- configResult.GetValue(), MaxConfigKeyLength, nullptr, nullptr) == 0)
+ configResult.GetValue(), charCount, nullptr, nullptr) == 0)
{
- // this should only happen if the config subsystem gives us a string that's not valid
- // unicode.
+ // this should never happen, the previous call to WideCharToMultiByte that computed the charCount should
+ // have caught all issues.
+ assert(false);
CLRConfig::FreeConfigString(out);
return false;
}