Fix HookConVarChange giving stale convar pointers when a plugin made the convar longer, triggering realloc (#2423)

This commit is contained in:
bottiger1
2026-03-29 20:11:12 +02:00
committed by GitHub
parent 6bb0b3aaa6
commit a327a80fcd
+7 -1
View File
@@ -650,10 +650,16 @@ void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue, float
{
ConVarReentrancyGuard guard(pConVar);
/* Copy the new value to a local buffer so it survives reentrant
* ChangeStringValue calls that may delete[] + reallocate m_pszString
* while the forward is still iterating plugin callbacks. */
char newValue[512];
strncpy(newValue, pConVar->GetString(), sizeof(newValue));
/* Now call forwards in plugins that have hooked this */
pForward->PushCell(pInfo->handle);
pForward->PushString(oldValue);
pForward->PushString(pConVar->GetString());
pForward->PushString(newValue);
pForward->Execute(NULL);
}
}