Skip to content

Commit

Permalink
Merge pull request #230 from Ni3znajomy/fix-checking-cvar-bounds
Browse files Browse the repository at this point in the history
Fix checking cvar's bounds
  • Loading branch information
Arkshine committed Mar 26, 2015
2 parents 69d41b6 + 4d3c49f commit bebe9f8
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions amxmodx/cvars.cpp
Expand Up @@ -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)
{
LogError(amx, AMX_ERR_NATIVE, "The minimum value can not be above the maximum value");
return 0;
}
else if (hasMin && maxVal < minVal)

if (hasMin && hasMax)
{
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());
Expand Down Expand Up @@ -723,4 +726,4 @@ AMX_NATIVE_INFO g_CvarNatives[] =
{"query_client_cvar", query_client_cvar},

{NULL, NULL}
};
};

0 comments on commit bebe9f8

Please sign in to comment.