Prevent crash in gettok() and similar functions by checking for NULL
input. Return NULL instead.
This commit is contained in:
parent
04ded78ef6
commit
e9fcb9b332
|
|
@ -393,6 +393,9 @@ gettok(char **s)
|
|||
int paren;
|
||||
const char *token, *token_e;
|
||||
|
||||
if (!*s)
|
||||
return NULL;
|
||||
|
||||
paren = 0;
|
||||
|
||||
*s = skip_ws(*s);
|
||||
|
|
@ -599,6 +602,10 @@ void findtok_noparen(char **p_str, char **p_token, char **p_token_end)
|
|||
char *gettok_noparens(char **s)
|
||||
{
|
||||
char *token, *token_e;
|
||||
|
||||
if (!*s)
|
||||
return NULL;
|
||||
|
||||
findtok_noparen(s, &token, &token_e);
|
||||
if (token == (char *) NULL) {
|
||||
return (char *) NULL; /* return NULL if we come to end of line */
|
||||
|
|
@ -654,6 +661,10 @@ void findtok_np(char** p_str, char** p_token, char** p_token_end)
|
|||
char* gettok_np(char** s)
|
||||
{
|
||||
char* token, * token_e;
|
||||
|
||||
if (!*s)
|
||||
return NULL;
|
||||
|
||||
findtok_np(s, &token, &token_e);
|
||||
if (token == (char*)NULL) {
|
||||
return (char*)NULL; /* return NULL if we come to end of line */
|
||||
|
|
@ -673,6 +684,9 @@ gettok_model(char **s)
|
|||
char c;
|
||||
const char *token, *token_e;
|
||||
|
||||
if (!*s)
|
||||
return NULL;
|
||||
|
||||
*s = skip_ws(*s);
|
||||
|
||||
if (!**s)
|
||||
|
|
@ -706,6 +720,9 @@ gettok_instance(char **s)
|
|||
char c;
|
||||
const char *token, *token_e;
|
||||
|
||||
if (!*s)
|
||||
return NULL;
|
||||
|
||||
*s = skip_ws(*s);
|
||||
|
||||
if (!**s)
|
||||
|
|
@ -740,6 +757,9 @@ gettok_char(char **s, char p, bool inc_p, bool nested)
|
|||
char c;
|
||||
const char *token, *token_e;
|
||||
|
||||
if (!*s)
|
||||
return NULL;
|
||||
|
||||
*s = skip_ws(*s);
|
||||
|
||||
if (!**s)
|
||||
|
|
|
|||
Loading…
Reference in New Issue