2017-07-06 16:08:15

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH 1/1] obexd: Fix memory leak in phonebook-dummy

g_build_filename() returns a newly-allocated string
that must be freed with g_free().
---
obexd/plugins/phonebook-dummy.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c
index 29ae889..b9e3a0d 100644
--- a/obexd/plugins/phonebook-dummy.c
+++ b/obexd/plugins/phonebook-dummy.c
@@ -524,6 +524,9 @@ void *phonebook_get_entry(const char *folder, const char *id,
filename = g_build_filename(root_folder, folder, id, NULL);

fd = open(filename, O_RDONLY);
+
+ g_free(filename);
+
if (fd < 0) {
DBG("open(): %s(%d)", strerror(errno), errno);
if (err)
--
1.7.9.5



2017-07-07 07:43:51

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/1] obexd: Fix memory leak in phonebook-dummy

Hi Syam,

On Thu, Jul 6, 2017 at 7:08 PM, Syam Sidhardhan <[email protected]> wrote:
> g_build_filename() returns a newly-allocated string
> that must be freed with g_free().
> ---
> obexd/plugins/phonebook-dummy.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c
> index 29ae889..b9e3a0d 100644
> --- a/obexd/plugins/phonebook-dummy.c
> +++ b/obexd/plugins/phonebook-dummy.c
> @@ -524,6 +524,9 @@ void *phonebook_get_entry(const char *folder, const char *id,
> filename = g_build_filename(root_folder, folder, id, NULL);
>
> fd = open(filename, O_RDONLY);
> +
> + g_free(filename);
> +
> if (fd < 0) {
> DBG("open(): %s(%d)", strerror(errno), errno);
> if (err)
> --
> 1.7.9.5

Applied, thanks.

--
Luiz Augusto von Dentz