diff options
author | Gopal Tiwari <gtiwari@redhat.com> | 2022-05-31 13:11:10 +0530 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-05-31 12:51:45 -0700 |
commit | 4ae130455b173650f564d92f7908a7ca4f7b1ee6 (patch) | |
tree | 7bf303afe8e1c2c1058a79b8d53b1def621818de /tools | |
parent | f4743109f381a4d53b476c5b77c7c68a6aa40b59 (diff) | |
download | bluez-4ae130455b173650f564d92f7908a7ca4f7b1ee6.tar.gz |
create-image: Fix leaked_handle
While performing static tool analysis using coverity found following
reports for resouse leak
bluez-5.64/tools/create-image.c:124: leaked_storage: Variable "map"
going out of scope leaks the storage it points to.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/create-image.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/create-image.c b/tools/create-image.c index aba940da7..90cd87315 100644 --- a/tools/create-image.c +++ b/tools/create-image.c @@ -97,12 +97,13 @@ static void write_block(FILE *fp, const char *pathname, unsigned int ino, map = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if (!map || map == MAP_FAILED) { - close(fd); - fd = -1; map = NULL; st.st_size = 0; } + close(fd); + fd = -1; + done: fprintf(fp, HDR_FMT, HDR_MAGIC, ino, mode, 0, 0, 1, 0, (uintmax_t) st.st_size, 0, 0, 0, 0, namelen + 1, 0, name); @@ -117,9 +118,7 @@ done: pad = 3 - ((st.st_size + 3) % 4); for (i = 0; i < pad; i++) fputc(0, fp); - munmap(map, st.st_size); - close(fd); } } |