From d2a1ee4e56182ba746053c6d41b6f29a2ce5554b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 16 May 2019 21:56:57 +0100 Subject: 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 --- include/strutils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') 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; } -- cgit v1.2.3-55-g7522