From 123d916b0ce9eaeb53c2d06ad6504729af8688ee Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sat, 4 Jan 2020 14:39:53 +0100 Subject: qkeyword: avoid NULL derefence if strtok_r's initial call returns NULL Signed-off-by: Fabian Groffen --- qkeyword.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qkeyword.c') diff --git a/qkeyword.c b/qkeyword.c index 0078fda..9c76858 100644 --- a/qkeyword.c +++ b/qkeyword.c @@ -190,13 +190,13 @@ read_keywords(char *s, int *keywords) if (!slen) return 0; - arch = strtok_r(s, delim, &savep); - do { + while ((arch = strtok_r(s, delim, &savep)) != NULL) { + s = NULL; /* for strtok_r */ i = decode_arch(arch); if (i == -1) continue; keywords[i] = decode_status(arch[0]); - } while ((arch = strtok_r(NULL, delim, &savep))); + } return 0; } -- cgit v1.2.3-65-gdbad