mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Tier1: properly handle null string values in ConVar::InternalSetValue
There is code that checks if the given string is nullptr, and if so, sets it to an empty string (""). But this new pointer wasn't used on InternalSetColorFromString and atof. InternalSetColorFromString calls sscanf on the given string which if null, is undefined behavior. The bug was also present in the engine code, this has been patched on assembly level and confirmed correct.
This commit is contained in:
parent
291a99e3ae
commit
bf7f128acf
@ -103,7 +103,7 @@ public:
|
||||
|
||||
// Utilities for convars accessed by the material system thread
|
||||
virtual bool IsMaterialThreadSetAllowed() const = 0;
|
||||
virtual void QueueMaterialThreadSetValue(ConVar* pConVar, const char* pValue) = 0;
|
||||
virtual void QueueMaterialThreadSetValue(ConVar* pConVar, const char* pValue/*pValue is allowed to be null*/) = 0;
|
||||
virtual void QueueMaterialThreadSetValue(ConVar* pConVar, int nValue) = 0;
|
||||
virtual void QueueMaterialThreadSetValue(ConVar* pConVar, float flValue) = 0;
|
||||
virtual bool HasQueuedMaterialThreadConVarSets() const = 0;
|
||||
|
@ -659,13 +659,13 @@ void ConVar::InternalSetValue(const char* value)
|
||||
if (!newVal)
|
||||
newVal = "";
|
||||
|
||||
if (!InternalSetColorFromString(value))
|
||||
if (!InternalSetColorFromString(newVal))
|
||||
{
|
||||
// Not a color, do the standard thing
|
||||
float fNewValue = (float)atof(value);
|
||||
float fNewValue = (float)atof(newVal);
|
||||
if (!IsFinite(fNewValue))
|
||||
{
|
||||
DevWarning(eDLL_T::COMMON, "Warning: %s = '%s' is infinite, clamping value.\n", GetName(), value);
|
||||
DevWarning(eDLL_T::COMMON, "Warning: %s = '%s' is infinite, clamping value.\n", GetName(), newVal);
|
||||
fNewValue = FLT_MAX;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user