mesh/mesh-db: Fix resource leaks
authorGopal Tiwari <gtiwari@redhat.com>
Tue, 31 May 2022 07:41:12 +0000 (13:11 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
While performing static tool analysis using coverity found following
reports for resouse leak

bluez-5.64/tools/mesh/mesh-db.c:2388: leaked_handle: Handle variable
"fd" going out of scope leaks the handle.

bluez-5.64/tools/mesh/mesh-db.c:2388: leaked_storage: Variable "str"
going out of scope leaks the storage it points to.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mesh/mesh-db.c

index 00cda86..86d7f08 100644 (file)
@@ -2386,6 +2386,8 @@ bool mesh_db_load(const char *fname)
 
        sz = read(fd, str, st.st_size);
        if (sz != st.st_size) {
+               close(fd);
+               l_free(str);
                l_error("Failed to read configuration file %s", fname);
                return false;
        }