Skip to content

Commit

Permalink
adsp_config.c: actually check error when parsing "version" array elem…
Browse files Browse the repository at this point in the history
…ents

Caveat: this was just reported by valgrind. I did not test any actual
toml parsing error either (who tests error handling?) but this code
can't be worse than the previous one.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and lgirdwood committed Sep 23, 2020
1 parent 75f9695 commit e67d68e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/adsp_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,11 +1565,15 @@ static int adsp_parse_config_fd(FILE *fd, struct adsp *out, bool verbose)
/* parse "version" array elements */
for (i = 0; i < ARRAY_SIZE(manifest_version); ++i) {
raw = toml_raw_at(arr, i);
if (ret < 0)
if (raw == 0) {
ret = err_key_parse("version", NULL);
goto error;
}
ret = toml_rtoi(raw, &manifest_version[i]);
if (ret < 0)
if (ret < 0) {
ret = err_key_parse("version", "can't convert element to integer");
goto error;
}
}

/* parsing function depends on manifest_version */
Expand Down

0 comments on commit e67d68e

Please sign in to comment.