From: AntonMoryakov Date: Thu, 24 Apr 2025 18:19:22 +0000 (+0300) Subject: ubifs-utils: common: fix memory leak in devtable.c X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2669111e3c60b8e146c174db5d2e7e9991f3dd87;p=mtd-utils.git ubifs-utils: common: fix memory leak in devtable.c Report of the static analyzer: Dynamic memory, referenced by 'line', is allocated at devtable.c:356 by calling function 'getline' and lost at devtable.c:388. (line: while (getline(&line, &len, f) != -1) {) Correct explained: Now line is freed in any exit scenario via out_close which eliminates this error. Triggers found by static analyzer Svace. Signed-off-by: Anton Moryakov Signed-off-by: David Oberhollenzer --- diff --git a/ubifs-utils/common/devtable.c b/ubifs-utils/common/devtable.c index 7347f09..2e581ff 100644 --- a/ubifs-utils/common/devtable.c +++ b/ubifs-utils/common/devtable.c @@ -392,6 +392,7 @@ int parse_devtable(const char *tbl_file) out_close: fclose(f); + free(line); free_devtable_info(); return -1; }