linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Fix memory textfile_get() memory leaks
@ 2005-09-07 11:31 Ville Nuorvala
  2005-09-07 11:58 ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Ville Nuorvala @ 2005-09-07 11:31 UTC (permalink / raw)
  To: bluez-devel

Hi,

there apparently are a couple of places where the bluez-utils is leaking 
memory after calling textfile_get(). The patch below should fix this...

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 11:23:14 -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 11:23:14 -0000
@@ -64,6 +64,8 @@
                 str = textfile_get(filename, key);
                 if (!str)
                         fprintf(stderr, "No value for %s\n", key);
+               else
+                       free(str);
         }

         return 0;


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


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] [PATCH] Fix memory textfile_get() memory leaks
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2005-09-07 11:58 UTC (permalink / raw)
  To: bluez-devel

Hi Ville,

> there apparently are a couple of places where the bluez-utils is leaking 
> memory after calling textfile_get(). The patch below should fix this...

coding style, coding style, coding style !!!

We use tabs instead of whitespaces. This means your patch is wrong or
your mailer screwed it up.

Regards

Marcel




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] [PATCH] Fix memory textfile_get() memory leaks
  2005-09-07 11:58 ` Marcel Holtmann
@ 2005-09-07 16:07   ` Ville Nuorvala
  2005-09-07 17:13     ` Ville Nuorvala
  0 siblings, 1 reply; 5+ messages in thread
From: Ville Nuorvala @ 2005-09-07 16:07 UTC (permalink / raw)
  To: bluez-devel

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

Marcel Holtmann wrote:
> Hi Ville,
> 
> 
>>there apparently are a couple of places where the bluez-utils is leaking 
>>memory after calling textfile_get(). The patch below should fix this...
> 
> 
> coding style, coding style, coding style !!!
> 
> We use tabs instead of whitespaces. This means your patch is wrong or
> your mailer screwed it up.

Sorry, the tabs got screwed up. The attached patch should be acceptable.

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.patch --]
[-- Type: text/x-patch, Size: 1085 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 14:36:58 -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 14:36:58 -0000
@@ -64,6 +64,8 @@
 		str = textfile_get(filename, key);
 		if (!str)
 			fprintf(stderr, "No value for %s\n", key);
+		else
+			free(str);
 	}
 
 	return 0;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] [PATCH] Fix memory textfile_get() memory leaks
  2005-09-07 16:07   ` Ville Nuorvala
@ 2005-09-07 17:13     ` Ville Nuorvala
  2005-09-07 17:25       ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Ville Nuorvala @ 2005-09-07 17:13 UTC (permalink / raw)
  To: bluez-devel

[-- 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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] [PATCH] Fix memory textfile_get() memory leaks
  2005-09-07 17:13     ` Ville Nuorvala
@ 2005-09-07 17:25       ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2005-09-07 17:25 UTC (permalink / raw)
  To: bluez-devel

Hi Ville,

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

ok, this one is now in the CVS. Thanks for looking at it. More fixes for
memory leaks are welcome ;)

Regards

Marcel




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-09-07 17:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2005-09-07 17:25       ` Marcel Holtmann

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).