Defensive programming, check bounds of loop variable first

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-01-07 02:51:15 +01:00
parent fe017642de
commit 338c358a75
+1 -1
View File
@@ -170,7 +170,7 @@ char *sanitize(char *arg, size_t len)
{
size_t i = 0;
while (isallowed(arg[i]) && i < len)
while (i < len && isallowed(arg[i]))
i++;
if (i + 1 < len) {