diff options
author | Sami Kerola | 2019-05-16 22:56:57 +0200 |
---|---|---|
committer | Sami Kerola | 2019-05-16 23:05:07 +0200 |
commit | d2a1ee4e56182ba746053c6d41b6f29a2ce5554b (patch) | |
tree | 9c5bb3ccd5f51ebc7d07d024a27a68f305b3efd2 /include | |
parent | lscpu: remove extra space from field key name (diff) | |
download | kernel-qcow2-util-linux-d2a1ee4e56182ba746053c6d41b6f29a2ce5554b.tar.gz kernel-qcow2-util-linux-d2a1ee4e56182ba746053c6d41b6f29a2ce5554b.tar.xz kernel-qcow2-util-linux-d2a1ee4e56182ba746053c6d41b6f29a2ce5554b.zip |
include/strutils: fix potential null pointer dereference
Recent lscpu fix caused gcc -Wnull-dereference to go off that this change
addresses.
Reference: b94acada9ed0e11a7e82f8f60280c5b6058e4250
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'include')
-rw-r--r-- | include/strutils.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/strutils.h b/include/strutils.h index 50733c5f5..d1f3da1b6 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -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; } |