payloads/libpayload/libc: Avoid NULL pointer dereference

Avoid dereferencing a NULL pointer in case of function parameter 'ptr'.

Signed-off-by: Harshit Sharma <harshitsharmajs@gmail.com>
Change-Id: I5dba27d9757fb55476f3d5848f0ed26ae9494bee
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41698
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Harshit Sharma 2020-05-26 00:29:53 +05:30 committed by Patrick Georgi
parent 8f27374768
commit 0d512179c5
1 changed files with 3 additions and 3 deletions

View File

@ -599,8 +599,6 @@ char *strtok_r(char *str, const char *delim, char **ptr)
return start; return start;
} }
static char **strtok_global;
/** /**
* Extract first token in string str that is delimited by a character in tokens. * Extract first token in string str that is delimited by a character in tokens.
* Destroys str, eliminates the token delimiter and uses global state. * Destroys str, eliminates the token delimiter and uses global state.
@ -610,7 +608,9 @@ static char **strtok_global;
*/ */
char *strtok(char *str, const char *delim) char *strtok(char *str, const char *delim)
{ {
return strtok_r(str, delim, strtok_global); static char *strtok_ptr;
return strtok_r(str, delim, &strtok_ptr);
} }
/** /**