From ac50f3ff34f774c25acafd45a6c35e5623457fce Mon Sep 17 00:00:00 2001 From: Arkshine Date: Wed, 28 Jan 2015 00:47:01 +0100 Subject: [PATCH] Cvars: Check lower/upper bounds in create_cvar as well --- amxmodx/cvars.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/amxmodx/cvars.cpp b/amxmodx/cvars.cpp index 3d16eea8..10486ed4 100644 --- a/amxmodx/cvars.cpp +++ b/amxmodx/cvars.cpp @@ -25,8 +25,30 @@ static cell AMX_NATIVE_CALL create_cvar(AMX *amx, cell *params) int flags = params[3]; bool hasMin = params[5] > 0 ? true : false; bool hasMax = params[7] > 0 ? true : false; - float minVal = amx_ctof(params[6]); - float maxVal = amx_ctof(params[8]); + float minVal = 0; + float maxVal = 0; + + if (hasMin) + { + minVal = amx_ctof(params[6]); + + if (hasMax && minVal > maxVal) + { + LogError(amx, AMX_ERR_NATIVE, "A lower bound can't be above an upper bound"); + return 0; + } + } + + if (hasMax) + { + maxVal = amx_ctof(params[8]); + + if (hasMin && maxVal < minVal) + { + LogError(amx, AMX_ERR_NATIVE, "An upper bound can't be below a lower bound"); + return 0; + } + } CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx);