linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] android/core: Fix memory leak in parse_system_id()
@ 2014-10-02 14:31 Andrei Emeltchenko
  2014-10-02 14:47 ` Szymon Janc
  0 siblings, 1 reply; 2+ messages in thread
From: Andrei Emeltchenko @ 2014-10-02 14:31 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

get_prop() allocates memory which needs to be freed.
---
 android/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/android/main.c b/android/main.c
index 4f3a6bf..703b3b6 100644
--- a/android/main.c
+++ b/android/main.c
@@ -382,9 +382,11 @@ static void parse_system_id(uint16_t len, const uint8_t *val)
 
 	res = strtoull(id, NULL, 16);
 	if (res == ULLONG_MAX && errno == ERANGE)
-		return;
+		goto done;
 
 	config_system_id = res;
+done:
+	free(id);
 }
 
 static void configuration(const void *buf, uint16_t len)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] android/core: Fix memory leak in parse_system_id()
  2014-10-02 14:31 [PATCH] android/core: Fix memory leak in parse_system_id() Andrei Emeltchenko
@ 2014-10-02 14:47 ` Szymon Janc
  0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-10-02 14:47 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

On Thursday 02 of October 2014 17:31:37 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> get_prop() allocates memory which needs to be freed.
> ---
>  android/main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/android/main.c b/android/main.c
> index 4f3a6bf..703b3b6 100644
> --- a/android/main.c
> +++ b/android/main.c
> @@ -382,9 +382,11 @@ static void parse_system_id(uint16_t len, const uint8_t *val)
>  
>  	res = strtoull(id, NULL, 16);
>  	if (res == ULLONG_MAX && errno == ERANGE)
> -		return;
> +		goto done;
>  
>  	config_system_id = res;
> +done:
> +	free(id);
>  }
>  
>  static void configuration(const void *buf, uint16_t len)
> 

Patch applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-02 14:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-02 14:31 [PATCH] android/core: Fix memory leak in parse_system_id() Andrei Emeltchenko
2014-10-02 14:47 ` Szymon Janc

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).