From 87c80b842cdec8c358efad40a1ff672dd839d26d Mon Sep 17 00:00:00 2001 From: h_vogt Date: Thu, 19 Jul 2012 23:16:15 +0200 Subject: [PATCH] gettok_char(), return(NULL) if substring not found --- src/misc/string.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/misc/string.c b/src/misc/string.c index 634ef409c..08249dd47 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -361,7 +361,8 @@ gettok_instance(char **s) } /* get the next token starting at next non white spice, stopping - at p, if inc_p is true, then including p, else excluding p + at p, if inc_p is true, then including p, else excluding p, + return NULL if p is not found */ char * gettok_char(char **s, char p, bool inc_p) @@ -382,6 +383,9 @@ gettok_char(char **s, char p, bool inc_p) ) { spice_dstring_append_char( &buf, *(*s)++ ) ; } + if (c == '\0') + /* p not found */ + return (NULL); if (inc_p) spice_dstring_append_char( &buf, *(*s)++ ) ;