]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/strutils: fix potential null pointer dereference
authorSami Kerola <kerolasa@iki.fi>
Thu, 16 May 2019 20:56:57 +0000 (21:56 +0100)
committerSami Kerola <kerolasa@iki.fi>
Thu, 16 May 2019 21:05:07 +0000 (22:05 +0100)
Recent lscpu fix caused gcc -Wnull-dereference to go off that this change
addresses.

Reference: b94acada9ed0e11a7e82f8f60280c5b6058e4250
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
include/strutils.h

index 50733c5f56dd68f9f75bf8e25afbe8dd0dd2a27a..d1f3da1b65f77159cf84ae2ddca0c74ff502d52c 100644 (file)
@@ -258,7 +258,9 @@ static inline void strrem(char *s, int rem)
 {
        char *p;
 
-       for (p = s; s && *s; s++) {
+       if (!s)
+               return;
+       for (p = s; *s; s++) {
                if (*s != rem)
                        *p++ = *s;
        }