linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ville Nuorvala <vnuorval@tcs.hut.fi>
To: bluez-devel@lists.sourceforge.net
Subject: Re: [Bluez-devel] [PATCH] Fix memory textfile_get() memory leaks
Date: Wed, 07 Sep 2005 20:13:00 +0300	[thread overview]
Message-ID: <431F1F9C.4010900@tcs.hut.fi> (raw)
In-Reply-To: <431F1041.3040603@tcs.hut.fi>

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

Sorry, I forgot to include stdlib.h in test_textfile.c. Please use this 
updated patch file...

Regards,
Ville

-- 
Ville Nuorvala
Research Assistant,
Laboratory for Theoretical Computer Science,
Helsinki University of Technology
email: vnuorval@tcs.hut.fi, phone: +358 (0)9 451 5257

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

Index: hcid/storage.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/storage.c,v
retrieving revision 1.24
diff -u -r1.24 storage.c
--- hcid/storage.c	30 Aug 2005 00:35:39 -0000	1.24
+++ hcid/storage.c	7 Sep 2005 17:10:05 -0000
@@ -87,6 +87,8 @@
 		str[248] = '\0';
 	strcpy(name, str);
 
+	free(str);
+
 	return 0;
 }
 
@@ -161,6 +163,7 @@
 		memcpy(tmp, str + (i * 2), 2);
 		key[i] = (uint8_t) strtol(tmp, NULL, 16);
 	}
+	free(str);
 
 	return 0;
 }
@@ -181,5 +184,7 @@
 	strncpy(pin, str, 16);
 	len = strlen(pin);
 
+	free(str);
+
 	return len;
 }
Index: common/test_textfile.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/test_textfile.c,v
retrieving revision 1.2
diff -u -r1.2 test_textfile.c
--- common/test_textfile.c	6 Aug 2005 06:27:40 -0000	1.2
+++ common/test_textfile.c	7 Sep 2005 17:10:05 -0000
@@ -35,7 +35,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
-
+#include <stdlib.h>
 #include "textfile.h"
 
 int main(int argc, char *argv[])
@@ -64,6 +64,8 @@
 		str = textfile_get(filename, key);
 		if (!str)
 			fprintf(stderr, "No value for %s\n", key);
+		else
+			free(str);
 	}
 
 	return 0;

  reply	other threads:[~2005-09-07 17:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-07 11:31 [Bluez-devel] [PATCH] Fix memory textfile_get() memory leaks Ville Nuorvala
2005-09-07 11:58 ` Marcel Holtmann
2005-09-07 16:07   ` Ville Nuorvala
2005-09-07 17:13     ` Ville Nuorvala [this message]
2005-09-07 17:25       ` Marcel Holtmann

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=431F1F9C.4010900@tcs.hut.fi \
    --to=vnuorval@tcs.hut.fi \
    --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 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).