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W5mbyAq
aXJrID0gTlVMTDsNCmNoYXIgKnN0cjsNCg0Kc3RyID0gZ19rZXlfZmlsZV9nZXRfc3RyaW5nKGtl
eV9maWxlLCAiSWRlbnRpdHlSZXNvbHZpbmdLZXkiLCAiS2V5IiwgTlVMTCk7DQppZiAoIXN0ciB8
fCBzdHJsZW4oc3RyKSA8IDMyKQ0KLSByZXR1cm4gTlVMTDsNCisgZ290byBmYWlsZWQ7DQoNCmly
ayA9IGdfbmV3MChzdHJ1Y3QgaXJrX2luZm8sIDEpOw0KDQpAQCAtMzEwOCw2ICszMTA4LDcgQEAg
c3RhdGljIHN0cnVjdCBpcmtfaW5mbyAqZ2V0X2lya19pbmZvKEdLZXlGaWxlICprZXlfZmlsZSwg
Y29uc3QgY2hhciAqcGVlciwNCmVsc2UNCnN0cjJidWYoJnN0clswXSwgaXJrLT52YWwsIHNpemVv
ZihpcmstPnZhbCkpOw0KDQorZmFpbGVkOg0KZ19mcmVlKHN0cik7DQoNCnJldHVybiBpcms7DQot
LSANCjEuNy45LjUNCg0KUGluZw==




2016-02-11 14:14:06

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/1] adapter: Fix memory leak

Hi Syam,

On Mon, Feb 8, 2016 at 5:02 PM, SYAM SIDHARDHAN <[email protected]> wrote:
>
> Hi,
> ------- Original Message -------
> Sender : SYAM SIDHARDHAN<[email protected]> ./Senior Chief Engineer/SRI-Bangalore-System & Connectivity/Samsung Electronics
> Date : Feb 03, 2016 20:28 (GMT+05:30)
> Title : [PATCH 1/1] adapter: Fix memory leak
>
> if strlen(str) < 32 then there is a memory leak.
> ---
> src/adapter.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index b184eed..f4fbf82 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -3091,12 +3091,12 @@ static GSList *get_ltk_info(GKeyFile *key_file, const char *peer,
> static struct irk_info *get_irk_info(GKeyFile *key_file, const char *peer,
> uint8_t bdaddr_type)
> {
> - struct irk_info *irk;
> + struct irk_info *irk = NULL;
> char *str;
>
> str = g_key_file_get_string(key_file, "IdentityResolvingKey", "Key", NULL);
> if (!str || strlen(str) < 32)
> - return NULL;
> + goto failed;
>
> irk = g_new0(struct irk_info, 1);
>
> @@ -3108,6 +3108,7 @@ static struct irk_info *get_irk_info(GKeyFile *key_file, const char *peer,
> else
> str2buf(&str[0], irk->val, sizeof(irk->val));
>
> +failed:
> g_free(str);
>
> return irk;
> --
> 1.7.9.5
>

Applied, thanks.


--
Luiz Augusto von Dentz