From e67d68e8e1ea34f2c434ccba21c9609fac8c5989 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 23 Sep 2020 05:03:30 +0000 Subject: [PATCH] adsp_config.c: actually check error when parsing "version" array elements 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 --- src/adsp_config.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/adsp_config.c b/src/adsp_config.c index a604383..d2269b8 100644 --- a/src/adsp_config.c +++ b/src/adsp_config.c @@ -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 */