[linux-nfc] [neard][PATCH 12/16] snep-send: fix near_ndef_message memory leak

Krzysztof Kozlowski <[email protected]>
Newsgroups org.01.lists.linux-nfc,dev.linux.lists.oe-linux-nfc
Message-ID <[email protected]>
The result of near_ndef_prepare_text_record() should be freed, otherwise
it leaks making ASAN and valgrind unhappy.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
 tools/snep-send.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/snep-send.c b/tools/snep-send.c
index 5bb153210d30..53f53250b1ae 100644
--- a/tools/snep-send.c
+++ b/tools/snep-send.c
@@ -91,6 +91,7 @@ int main(int argc, char *argv[])
 	frame = g_try_malloc0(frame_length);
 	if (!frame) {
 		close(fd);
+		near_ndef_msg_free(ndef);
 		near_error("Could not allocate SNEP frame");
 		return -1;
 	}
@@ -100,6 +101,7 @@ int main(int argc, char *argv[])
 	frame->length = GUINT_TO_BE(ndef->length);
 
 	memcpy(frame->ndef, ndef->data, ndef->length);
+	near_ndef_msg_free(ndef);
 
 	len = send(fd, (uint8_t *)frame, frame_length, 0);
 	if (len < 0) {
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.