This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
A patch for memory leak in gas
- To: binutils at sourceware dot cygnus dot com
- Subject: A patch for memory leak in gas
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Fri, 29 Dec 2000 13:59:25 -0800
There may be a memory leak in listing_message (). Here is a patch.
--
H.J. Lu (hjl@valinux.com)
---
2000-12-29 H.J. Lu <hjl@gnu.org>
* listing.c (listing_message): Allocate string only if it is
used.
Index: listing.c
===================================================================
RCS file: /work/cvs/gnu/binutils/gas/listing.c,v
retrieving revision 1.6
diff -u -p -r1.6 listing.c
--- listing.c 2000/11/08 00:33:58 1.6
+++ listing.c 2000/12/29 21:56:49
@@ -226,12 +226,12 @@ listing_message (name, message)
const char *name;
const char *message;
{
- unsigned int l = strlen (name) + strlen (message) + 1;
- char *n = (char *) xmalloc (l);
- strcpy (n, name);
- strcat (n, message);
if (listing_tail != (list_info_type *) NULL)
{
+ unsigned int l = strlen (name) + strlen (message) + 1;
+ char *n = (char *) xmalloc (l);
+ strcpy (n, name);
+ strcat (n, message);
listing_tail->message = n;
}
}