Skip to content

Commit

Permalink
ft_config: Check return values from jsmn parser
Browse files Browse the repository at this point in the history
Issue reported by coverity.

Signed-off-by: Sean Hefty <[email protected]>
  • Loading branch information
shefty committed Oct 12, 2015
1 parent 0e180ea commit aff4f34
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions complex/ft_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,12 @@ static int ft_parse_config(char *config, int size,

jsmn_init(&parser);
num_tokens = jsmn_parse(&parser, config, size, NULL, 0);
if (num_tokens <= 0)
return 1;

tokens = malloc(sizeof(jsmntok_t) * num_tokens);
if (!tokens)
return 1;

/* jsmn parser returns a list of JSON tokens (jsmntok_t)
* e.g. JSMN_OBJECT
Expand Down

0 comments on commit aff4f34

Please sign in to comment.