summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-04-10 16:09:08 +0200
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-04-10 16:09:08 +0200
commit8cf27972c87572e9b256e00a226fdaf275a1a43e (patch)
treef5492f21b2cba1515a7a0a8c7025b0838b79dde3
parent42a9fabacefc5595cc37448e6493fa51f1b75bf5 (diff)
downloadratpoison-8cf27972c87572e9b256e00a226fdaf275a1a43e.zip
strtok_ws: account for erroneous usage
* if s and last are both NULL then we'll get a fatal error; instead of waiting for the segfault, display an error message and call abort()
-rw-r--r--src/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 4e733c2..1f815e9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -171,8 +171,13 @@ strtok_ws (char *s)
char *nonws;
static char *last = NULL;
- if (s)
+ if (s == NULL)
last = s;
+ else if (last == NULL)
+ {
+ PRINT_ERROR (("strtok_ws() called but not initalized, this is a *BUG*\n"));
+ abort();
+ }
/* skip to first non-whitespace char. */
while (*last && isspace (*last)) last++;