forked from lda/telodendria
Check return value of fgets() in Json.c
This commit is contained in:
parent
a24d9b6c29
commit
76937a57a4
1 changed files with 18 additions and 3 deletions
21
src/Json.c
21
src/Json.c
|
@ -791,7 +791,12 @@ JsonTokenSeek(JsonParserState * state)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 't':
|
case 't':
|
||||||
fgets(state->token, 5, state->stream);
|
if (!fgets(state->token, 5, state->stream))
|
||||||
|
{
|
||||||
|
state->tokenType = TOKEN_EOF;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp("true", state->token))
|
if (!strcmp("true", state->token))
|
||||||
{
|
{
|
||||||
state->tokenType = TOKEN_BOOLEAN;
|
state->tokenType = TOKEN_BOOLEAN;
|
||||||
|
@ -803,7 +808,12 @@ JsonTokenSeek(JsonParserState * state)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
fgets(state->token, 6, state->stream);
|
if (!fgets(state->token, 6, state->stream))
|
||||||
|
{
|
||||||
|
state->tokenType = TOKEN_EOF;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp("false", state->token))
|
if (!strcmp("false", state->token))
|
||||||
{
|
{
|
||||||
state->tokenType = TOKEN_BOOLEAN;
|
state->tokenType = TOKEN_BOOLEAN;
|
||||||
|
@ -815,7 +825,12 @@ JsonTokenSeek(JsonParserState * state)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
fgets(state->token, 5, state->stream);
|
if (!fgets(state->token, 5, state->stream))
|
||||||
|
{
|
||||||
|
state->tokenType = TOKEN_EOF;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp("null", state->token))
|
if (!strcmp("null", state->token))
|
||||||
{
|
{
|
||||||
state->tokenType = TOKEN_NULL;
|
state->tokenType = TOKEN_NULL;
|
||||||
|
|
Loading…
Reference in a new issue