]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: check limits before indexing array [cppcheck]
authorBoris Egorov <egorov@linux.com>
Tue, 19 Jan 2016 06:16:03 +0000 (12:16 +0600)
committerBoris Egorov <egorov@linux.com>
Tue, 19 Jan 2016 06:59:12 +0000 (12:59 +0600)
[libblkid/src/encode.c:165]: (style) Array index 'i' is used before limits check.

libblkid/src/encode.c

index 466e4540f9c768d266941e1c16590491e798cb87..b5b4363afff2f99b0d1f80ec0d0252fbfe39d7ed 100644 (file)
@@ -162,7 +162,7 @@ static int replace_whitespace(const char *str, char *to, size_t len)
 
        /* strip leading whitespace */
        i = 0;
-       while (isspace(str[i]) && (i < len))
+       while ((i < len) && isspace(str[i]))
                i++;
 
        j = 0;