summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalbir singh <bsingharora@gmail.com>2018-05-18 09:31:00 +1000
committerStewart Smith <stewart@linux.ibm.com>2018-05-24 04:03:19 -0500
commitad58f8da1d4fbd45abf163514a9643a14e1636ee (patch)
treeb2128ef5a45a50ba7adce1e0d4306b6bdaadf7ac
parent53dac89cb8aab986e08ea5e062564f3da9f4831f (diff)
downloadtalos-skiboot-ad58f8da1d4fbd45abf163514a9643a14e1636ee.tar.gz
talos-skiboot-ad58f8da1d4fbd45abf163514a9643a14e1636ee.zip
Fix strtok for previous tokens being NULL
Caught by scan-build. If the stored token nxtTok is already NULL, don't dereference src Signed-off-by: Balbir singh <bsingharora@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
-rw-r--r--libc/string/strtok.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libc/string/strtok.c b/libc/string/strtok.c
index 665c08db..aa42d77e 100644
--- a/libc/string/strtok.c
+++ b/libc/string/strtok.c
@@ -18,8 +18,11 @@ strtok(char *src, const char *pattern)
static char *nxtTok;
char *retVal = NULL;
- if (!src)
+ if (!src) {
src = nxtTok;
+ if (!src)
+ return retVal;
+ }
while (*src) {
const char *pp = pattern;
OpenPOWER on IntegriCloud