commit: 123d916b0ce9eaeb53c2d06ad6504729af8688ee Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Sat Jan 4 13:39:53 2020 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Sat Jan 4 13:39:53 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=123d916b
qkeyword: avoid NULL derefence if strtok_r's initial call returns NULL Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> qkeyword.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; }