From: Szymon Janc Date: Tue, 7 Aug 2012 12:22:32 +0000 (+0200) Subject: nfctype3: Fix possible memory leak in nfctype3_read X-Git-Tag: 0.6~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b398abc290d05f711b8b7be5a174c0a79afa026c;p=platform%2Fupstream%2Fneard.git nfctype3: Fix possible memory leak in nfctype3_read If call to near_adapter_send() failed cookie should be freed before returning. --- diff --git a/plugins/nfctype3.c b/plugins/nfctype3.c index 6ccadaf..7349b88 100644 --- a/plugins/nfctype3.c +++ b/plugins/nfctype3.c @@ -403,6 +403,7 @@ static int nfctype3_read(uint32_t adapter_idx, { struct type3_cmd cmd; struct t3_cookie *cookie; + int err; DBG(""); @@ -424,8 +425,12 @@ static int nfctype3_read(uint32_t adapter_idx, cookie->target_idx = target_idx; cookie->cb = cb; - return near_adapter_send(adapter_idx, (uint8_t *)&cmd, - cmd.len , nfctype3_recv_UID, cookie); + err = near_adapter_send(adapter_idx, (uint8_t *)&cmd, + cmd.len , nfctype3_recv_UID, cookie); + if (err < 0) + g_free(cookie); + + return err; } static int update_attr_block_cb(uint8_t *resp, int length, void *data)