From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14584 invoked by alias); 9 May 2005 15:20:31 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 14406 invoked from network); 9 May 2005 15:20:21 -0000 Received: from unknown (HELO emea1-mh.id2.novell.com) (195.33.99.129) by sourceware.org with SMTP; 9 May 2005 15:20:21 -0000 Received: from EMEA1-MTA by emea1-mh.id2.novell.com with Novell_GroupWise; Mon, 09 May 2005 16:20:20 +0200 Message-Id: Date: Mon, 09 May 2005 15:21:00 -0000 From: "Jan Beulich" To: Subject: [PATCH] eliminate memory leak during macro definition Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part80A3B0AA.0__=" X-SW-Source: 2005-05/txt/msg00347.txt.bz2 This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part80A3B0AA.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 1371 This eliminates another memory leak on handling macros. Built and tested natively on x86_64-unknown-linux-gnu and as cross tools for a large number of targets. Jan gas/ 2005-05-09 Jan Beulich * read.c (s_macro): Move local variable 'local' to smaller scope. Call sb_kill on it when done. --- /home/jbeulich/src/binutils/mainline/2005-05-06/gas/read.c 2005-05-06 0= 8:34:42.000000000 +0200 +++ 2005-05-06/gas/read.c 2005-05-09 11:57:39.038134712 +0200 @@ -2348,7 +2348,6 @@ s_macro (int ignore ATTRIBUTE_UNUSED) char *file; unsigned int line; sb s; - sb label; const char *err; const char *name; =20 @@ -2358,11 +2357,17 @@ s_macro (int ignore ATTRIBUTE_UNUSED) while (!is_end_of_line[(unsigned char) *input_line_pointer]) sb_add_char (&s, *input_line_pointer++); =20 - sb_new (&label); if (line_label !=3D NULL) - sb_add_string (&label, S_GET_NAME (line_label)); + { + sb label; =20 - err =3D define_macro (0, &s, &label, get_line_sb, file, line, &name); + sb_new (&label); + sb_add_string (&label, S_GET_NAME (line_label)); + err =3D define_macro (0, &s, &label, get_line_sb, file, line, &name); + sb_kill (&label); + } + else + err =3D define_macro (0, &s, NULL, get_line_sb, file, line, &name); if (err !=3D NULL) as_bad_where (file, line, err, name); else --=__Part80A3B0AA.0__= Content-Type: text/plain; name="binutils-mainline-macro-label-leak.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="binutils-mainline-macro-label-leak.patch" Content-length: 1351 This eliminates another memory leak on handling macros. Built and tested natively on x86_64-unknown-linux-gnu and as cross tools for a large number of targets. Jan gas/ 2005-05-09 Jan Beulich * read.c (s_macro): Move local variable 'local' to smaller scope. Call sb_kill on it when done. --- /home/jbeulich/src/binutils/mainline/2005-05-06/gas/read.c 2005-05-06 08:34:42.000000000 +0200 +++ 2005-05-06/gas/read.c 2005-05-09 11:57:39.038134712 +0200 @@ -2348,7 +2348,6 @@ s_macro (int ignore ATTRIBUTE_UNUSED) char *file; unsigned int line; sb s; - sb label; const char *err; const char *name; @@ -2358,11 +2357,17 @@ s_macro (int ignore ATTRIBUTE_UNUSED) while (!is_end_of_line[(unsigned char) *input_line_pointer]) sb_add_char (&s, *input_line_pointer++); - sb_new (&label); if (line_label != NULL) - sb_add_string (&label, S_GET_NAME (line_label)); + { + sb label; - err = define_macro (0, &s, &label, get_line_sb, file, line, &name); + sb_new (&label); + sb_add_string (&label, S_GET_NAME (line_label)); + err = define_macro (0, &s, &label, get_line_sb, file, line, &name); + sb_kill (&label); + } + else + err = define_macro (0, &s, NULL, get_line_sb, file, line, &name); if (err != NULL) as_bad_where (file, line, err, name); else --=__Part80A3B0AA.0__=--