summaryrefslogtreecommitdiff
path: root/sys/src/libjson
diff options
context:
space:
mode:
authorBurnZeZ <brz-9dev@intma.in>2013-11-10 03:35:25 -0500
committerBurnZeZ <brz-9dev@intma.in>2013-11-10 03:35:25 -0500
commit983413de75dafe1794f131274bc18c5e30429e51 (patch)
tree78a22734ef58947bd7f2c8a636ee68f2582079e0 /sys/src/libjson
parentf0483642be7ab5663daca6784f39e593d3e53ea2 (diff)
libjson: don't perform chartorune in getch() when char is null terminator, and remove empty string check added last commit
Diffstat (limited to 'sys/src/libjson')
-rw-r--r--sys/src/libjson/json.c9
1 files changed, 4 insertions, 5 deletions
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);