From 983413de75dafe1794f131274bc18c5e30429e51 Mon Sep 17 00:00:00 2001 From: BurnZeZ Date: Sun, 10 Nov 2013 03:35:25 -0500 Subject: libjson: don't perform chartorune in getch() when char is null terminator, and remove empty string check added last commit --- sys/src/libjson/json.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sys/src/libjson/json.c') diff --git a/sys/src/libjson/json.c b/sys/src/libjson/json.c index 8d9b7bd91..4a671c4e5 100644 --- a/sys/src/libjson/json.c +++ b/sys/src/libjson/json.c @@ -36,6 +36,8 @@ getch(Lex *l) l->peeked = 0; return r; } + if(l->s[0] == '\0') + return 0; l->s += chartorune(&r, l->s); return r; } @@ -318,11 +320,8 @@ jsonparse(char *s) memset(&l, 0, sizeof(l)); l.s = s; - if((l.slen = strlen(s)) == 0){ - werrstr("empty string"); - return nil; - } - if((l.buf = mallocz(l.slen, 1)) == nil) + l.slen = strlen(s); + if((l.buf = mallocz(l.slen+1, 1)) == nil) return nil; j = jsonobj(&l); -- cgit v1.2.3