diff options
author | Kamil Dudka <kdudka@redhat.com> | 2021-03-18 18:49:08 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-03-18 18:49:08 +0100 |
commit | 722325fba8968a26eb243642cbe89a044d6dfd6c (patch) | |
tree | 7f394e39161ccc6d8117cf9e218195308a776ea0 | |
parent | cecafc8cd5cd725444b914d5f6cd17308633afa8 (diff) |
Fix fd leak in error path
shared-mime-info-2.1/xdgmime/src/print-mime-data.c:66: alloc_fn: Storage is returned from allocation function "fopen".
shared-mime-info-2.1/xdgmime/src/print-mime-data.c:66: var_assign: Assigning: "file" = storage returned from "fopen(filename, "r")".
shared-mime-info-2.1/xdgmime/src/print-mime-data.c:80: leaked_storage: Variable "file" going out of scope leaks the storage it points to.
78| {
79| printf ("Failed to allocate memory for file %s\n", filename);
80|-> return;
81| }
82|
shared-mime-info-2.1/xdgmime/src/test-mime-data.c:113: alloc_fn: Storage is returned from allocation function "fopen".
shared-mime-info-2.1/xdgmime/src/test-mime-data.c:113: var_assign: Assigning: "file" = storage returned from "fopen(path, "r")".
shared-mime-info-2.1/xdgmime/src/test-mime-data.c:131: leaked_storage: Variable "file" going out of scope leaks the storage it points to.
129| error++;
130|
131|-> return;
132| }
133|
-rw-r--r-- | src/print-mime-data.c | 1 | ||||
-rw-r--r-- | src/test-mime-data.c | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/print-mime-data.c b/src/print-mime-data.c index c66a4db..2549e73 100644 --- a/src/print-mime-data.c +++ b/src/print-mime-data.c @@ -77,6 +77,7 @@ test_by_data (const char *filename) if (data == NULL) { printf ("Failed to allocate memory for file %s\n", filename); + fclose (file); return; } diff --git a/src/test-mime-data.c b/src/test-mime-data.c index b4dffbb..1dbc636 100644 --- a/src/test-mime-data.c +++ b/src/test-mime-data.c @@ -128,6 +128,7 @@ test_by_data (const char *dir, printf ("Failed to allocate memory for file %s\n", filename); error++; + fclose (file); return; } |