Skip to contentSkip to conversation

fsdev: fix memory leak in main()

PATCH In review ZhiPeng Lu 2 participants 2 messages Jul 27, 2017

lore
Share & tools
lore

ZhiPeng Lu

author
#0 lore raw

PATCH 1/1 fsdev: fix memory leak in main()

@rpath and @ sock_name are not freed and leaked.

---
 fsdev/virtfs-proxy-helper.c | 2 ++
 1 file changed, 2 insertions(+)
fsdev/virtfs-proxy-helper.c +2 -0
index 6c066ec..8e48500 100644
@@ -1162,6 +1162,8 @@ int main(int argc, char **argv)
 
     process_requests(sock);
 error:
+    g_free(rpath);
+    g_free(sock_name);
     do_log(LOG_INFO, "Done\n");
     closelog();
     return 0;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 2 lines · On Thu, 27 Jul 2017 08:31:42 +0800 ZhiPeng Lu <[email protected]> wrote:

@rpath and @ sock_name are not freed and leaked.

The leak is harmless since the process is expected to terminate when main() returns. So, even if I fully agree that we should always take care of allocated memory, I will push it to my 9p-next branch and wait for 2.11 before pushing it upstream.

Quoted 18 lines
---
 fsdev/virtfs-proxy-helper.c | 2 ++
 1 file changed, 2 insertions(+)
fsdev/virtfs-proxy-helper.c +2 -0
index 6c066ec..8e48500 100644
@@ -1162,6 +1162,8 @@ int main(int argc, char **argv)
 
     process_requests(sock);
 error:
+    g_free(rpath);
+    g_free(sock_name);
     do_log(LOG_INFO, "Done\n");
     closelog();
     return 0;