* [PATCH] tools/obex-client-tool.c: Fix memory leak in obex-client-tool
@ 2015-06-26 13:05 Anupam Roy
0 siblings, 0 replies; 3+ messages in thread
From: Anupam Roy @ 2015-06-26 13:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: sachin.dev, Anupam Roy
GOptionContext object should be freed in case socket connection
fails and program execution is terminated.
==12968== HEAP SUMMARY:
==12968== in use at exit: 2,895 bytes in 14 blocks
==12968== total heap usage: 23 allocs, 9 frees, 36,669 bytes allocated
==12968==
==12968== 624 (88 direct, 536 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 14
==12968== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12968== by 0x4E85668: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==12968== by 0x4E89D22: g_option_context_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==12968== by 0x402BAB: main (obex-client-tool.c:428)
==12968==
==12968== LEAK SUMMARY:
==12968== definitely lost: 88 bytes in 1 blocks
==12968== indirectly lost: 536 bytes in 2 blocks
==12968== possibly lost: 0 bytes in 0 blocks
==12968== still reachable: 2,271 bytes in 11 blocks
==12968== suppressed: 0 bytes in 0 blocks
---
tools/obex-client-tool.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/obex-client-tool.c b/tools/obex-client-tool.c
index 4f931f6..d0ba8a6 100644
--- a/tools/obex-client-tool.c
+++ b/tools/obex-client-tool.c
@@ -432,6 +432,7 @@ int main(int argc, char *argv[])
if (err != NULL) {
g_printerr("%s\n", err->message);
g_error_free(err);
+ g_option_context_free(context);
exit(EXIT_FAILURE);
}
@@ -445,8 +446,10 @@ int main(int argc, char *argv[])
else
io = unix_connect(transport);
- if (io == NULL)
+ if (io == NULL) {
+ g_option_context_free(context);
exit(EXIT_FAILURE);
+ }
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sig_term;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] tools/obex-client-tool.c: Fix memory leak in obex-client-tool
@ 2015-07-21 12:03 Anupam Roy
2015-07-24 13:59 ` Vinicius Costa Gomes
0 siblings, 1 reply; 3+ messages in thread
From: Anupam Roy @ 2015-07-21 12:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: sachin.dev
ping
> -----Original Message-----
>From: Anupam Roy <anupam.r@samsung.com>
>To: linux-bluetooth@vger.kernel.org
>Cc:sachin.dev@samsung.com; anupam.r@samsung.com
>Date: Fri, 26 Jun 2015 08:58:33 -0400
>Subject: [PATCH] tools/obex-client-tool.c: Fix memory leak in obex-client-tool
>
>GOptionContext object should be freed in case socket connection
>fails and program execution is terminated.
>
>==12968== HEAP SUMMARY:
>==12968== in use at exit: 2,895 bytes in 14 blocks
>==12968== total heap usage: 23 allocs, 9 frees, 36,669 bytes allocated
>==12968==
>==12968== 624 (88 direct, 536 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 14
>==12968== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>==12968== by 0x4E85668: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
>==12968== by 0x4E89D22: g_option_context_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
>==12968== by 0x402BAB: main (obex-client-tool.c:428)
>==12968==
>==12968== LEAK SUMMARY:
>==12968== definitely lost: 88 bytes in 1 blocks
>==12968== indirectly lost: 536 bytes in 2 blocks
>==12968== possibly lost: 0 bytes in 0 blocks
>==12968== still reachable: 2,271 bytes in 11 blocks
>==12968== suppressed: 0 bytes in 0 blocks
>---
> tools/obex-client-tool.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/tools/obex-client-tool.c b/tools/obex-client-tool.c
>index 4f931f6..d0ba8a6 100644
>--- a/tools/obex-client-tool.c
>+++ b/tools/obex-client-tool.c
>@@ -432,6 +432,7 @@ int main(int argc, char *argv[])
> if (err != NULL) {
> g_printerr("%s\n", err->message);
> g_error_free(err);
>+ g_option_context_free(context);
> exit(EXIT_FAILURE);
> }
>
>@@ -445,8 +446,10 @@ int main(int argc, char *argv[])
> else
> io = unix_connect(transport);
>
>- if (io == NULL)
>+ if (io == NULL) {
>+ g_option_context_free(context);
> exit(EXIT_FAILURE);
>+ }
>
> memset(&sa, 0, sizeof(sa));
> sa.sa_handler = sig_term;
>--
>1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] tools/obex-client-tool.c: Fix memory leak in obex-client-tool
2015-07-21 12:03 [PATCH] tools/obex-client-tool.c: Fix memory leak in obex-client-tool Anupam Roy
@ 2015-07-24 13:59 ` Vinicius Costa Gomes
0 siblings, 0 replies; 3+ messages in thread
From: Vinicius Costa Gomes @ 2015-07-24 13:59 UTC (permalink / raw)
To: Anupam Roy, linux-bluetooth; +Cc: sachin.dev
Hi,
Anupam Roy <anupam.r@samsung.com> writes:
> ping
>
>> -----Original Message-----
>>From: Anupam Roy <anupam.r@samsung.com>
>>To: linux-bluetooth@vger.kernel.org
>>Cc:sachin.dev@samsung.com; anupam.r@samsung.com
>>Date: Fri, 26 Jun 2015 08:58:33 -0400
>>Subject: [PATCH] tools/obex-client-tool.c: Fix memory leak in obex-client-tool
>>
>>GOptionContext object should be freed in case socket connection
>>fails and program execution is terminated.
>>
The code looks fine.
(But I didn't get the first email)
Cheers,
--
Vinicius
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-24 13:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-21 12:03 [PATCH] tools/obex-client-tool.c: Fix memory leak in obex-client-tool Anupam Roy
2015-07-24 13:59 ` Vinicius Costa Gomes
-- strict thread matches above, loose matches on Subject: below --
2015-06-26 13:05 Anupam Roy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).