aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-08 09:39:29 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:32 -0700
commit30fbaa8a02f8c726a6faf1be1e346c038f929dfb (patch)
tree7fe7b186183264554ace5b905f449210d992246f
parenta17b6c494fd8f2b9aae53b49bd462c984716c772 (diff)
downloadsparse-dev-30fbaa8a02f8c726a6faf1be1e346c038f929dfb.tar.gz
Handle bad strings gracefully.
We should never see a TOKEN_STRING of size 0, since we always add the final '\0' to the string. But bugs happen, and we'd rather see the problem than a SIGSEGV.
-rw-r--r--tokenize.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tokenize.c b/tokenize.c
index 180b523b..6b5c77cc 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -87,6 +87,8 @@ const char *show_string(const struct string *string)
char *ptr;
int i;
+ if (!string->length)
+ return "<bad_string>";
ptr = buffer;
*ptr++ = '"';
for (i = 0; i < string->length-1; i++) {