summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSami Kerola2019-05-16 22:56:57 +0200
committerSami Kerola2019-05-16 23:05:07 +0200
commitd2a1ee4e56182ba746053c6d41b6f29a2ce5554b (patch)
tree9c5bb3ccd5f51ebc7d07d024a27a68f305b3efd2 /include
parentlscpu: remove extra space from field key name (diff)
downloadkernel-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.h4
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;
}