All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manuel Naranjo <naranjo.manuel@gmail.com>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] [PATCH] SDP lib memory leak
Date: Fri, 31 Aug 2007 14:28:29 -0300	[thread overview]
Message-ID: <46D84FBD.60203@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

Marcel and team,
Hi folks, I have made an application that makes use of the sdp lib. By 
running the app with valgrind [1] I found a memory leak.
There's an static variable called bluetooth_base_uuid that's being 
initializated once but then never freed.
I had added a method that should be called, only when the thread is 
about to end that frees that variable.
Attached you can see the patch.
Thanks,
Manuel


[1] http://valgrind.org/


[-- Attachment #2: leak.patch --]
[-- Type: text/x-patch, Size: 1074 bytes --]

diff -uprN bluez-libs-3.17/include/sdp_lib.h bluez-libs-3.17.patched/include/sdp_lib.h
--- bluez-libs-3.17/include/sdp_lib.h	2007-05-09 03:40:39.000000000 -0300
+++ bluez-libs-3.17.patched/include/sdp_lib.h	2007-08-31 14:15:49.000000000 -0300
@@ -609,6 +609,9 @@ void sdp_pattern_add_uuidseq(sdp_record_
 
 int sdp_send_req_w4_rsp(sdp_session_t *session, uint8_t *req, uint8_t *rsp, uint32_t reqsize, uint32_t *rspsize);
 
+/** This function will cleanup the bluetooth base uuid, should be called only after the thread has ended it's work **/
+void sdp_cleanup();
+
 #ifdef __cplusplus
 }
 #endif
diff -uprN bluez-libs-3.17/src/sdp.c bluez-libs-3.17.patched/src/sdp.c
--- bluez-libs-3.17/src/sdp.c	2007-08-23 06:59:37.000000000 -0300
+++ bluez-libs-3.17.patched/src/sdp.c	2007-08-31 14:15:02.000000000 -0300
@@ -2152,6 +2152,11 @@ uint128_t *sdp_create_base_uuid(void)
 	return bluetooth_base_uuid;
 }
 
+void sdp_cleanup(){
+	if (bluetooth_base_uuid)
+		free(bluetooth_base_uuid);
+}
+
 uuid_t *sdp_uuid16_create(uuid_t *u, uint16_t val)
 {
 	memset(u, 0, sizeof(uuid_t));

[-- Attachment #3: Type: text/plain, Size: 315 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

             reply	other threads:[~2007-08-31 17:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-31 17:28 Manuel Naranjo [this message]
2007-08-31 18:45 ` [Bluez-devel] [PATCH] SDP lib memory leak Marcel Holtmann
2007-08-31 19:11   ` Manuel Naranjo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46D84FBD.60203@gmail.com \
    --to=naranjo.manuel@gmail.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.