From 4d3c49f93b046d1034995a018cff031ca430ff33 Mon Sep 17 00:00:00 2001 From: Ni3znajomy Date: Thu, 26 Mar 2015 21:31:16 +0100 Subject: [PATCH] Fix checking cvar's bounds --- amxmodx/cvars.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/amxmodx/cvars.cpp b/amxmodx/cvars.cpp index b3f52f5e..21db4793 100644 --- a/amxmodx/cvars.cpp +++ b/amxmodx/cvars.cpp @@ -39,16 +39,19 @@ static cell AMX_NATIVE_CALL create_cvar(AMX *amx, cell *params) bool hasMax = params[7] != 0; float minVal = amx_ctof(params[6]); float maxVal = amx_ctof(params[8]); - - if (hasMax && minVal > maxVal) + + if (hasMin && hasMax) { - LogError(amx, AMX_ERR_NATIVE, "The minimum value can not be above the maximum value"); - return 0; - } - else if (hasMin && maxVal < minVal) - { - LogError(amx, AMX_ERR_NATIVE, "The maximum value can not be below the minimum value"); - return 0; + if (minVal > maxVal) + { + LogError(amx, AMX_ERR_NATIVE, "The minimum value can not be above the maximum value"); + return 0; + } + else if (maxVal < minVal) + { + LogError(amx, AMX_ERR_NATIVE, "The maximum value can not be below the minimum value"); + return 0; + } } g_CvarManager.SetCvarMin(info, hasMin, minVal, plugin->getId()); @@ -723,4 +726,4 @@ AMX_NATIVE_INFO g_CvarNatives[] = {"query_client_cvar", query_client_cvar}, {NULL, NULL} -}; \ No newline at end of file +};