1
0
mirror of https://github.com/kdave/btrfs-progs synced 2025-04-11 03:31:17 +00:00

btrfs-progs: string-table: fix memory leak on exit path in table_vprintf()

Reported by 'gcc -fanalyzer:
common/string-table.c:62:17: warning: leak of ‘msg’ [CWE-401] [-Wanalyzer-malloc-leak]

The 'msg' still allocated when returning from the function due to error,
free it.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-04-03 23:13:54 +02:00
parent 27198a4c26
commit 9c156ab9ca

View File

@ -57,6 +57,7 @@ char *table_vprintf(struct string_table *tab, unsigned int column, unsigned int
return NULL; return NULL;
if (column >= tab->ncols || row >= tab->nrows) { if (column >= tab->ncols || row >= tab->nrows) {
free(msg);
error("attempt to write outside of table: col %u row %u fmt %s", error("attempt to write outside of table: col %u row %u fmt %s",
column, row, fmt); column, row, fmt);
return NULL; return NULL;