libjson: don't perform chartorune in getch() when char is null terminator, and remove empty string check added last commit

This commit is contained in:
BurnZeZ 2013-11-10 03:35:25 -05:00
parent f0483642be
commit 983413de75

View file

@ -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);