public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: <binutils@sources.redhat.com>
Subject: [PATCH] eliminate memory leak during macro definition
Date: Mon, 09 May 2005 15:21:00 -0000	[thread overview]
Message-ID: <s27f8dc4.034@emea1-mh.id2.novell.com> (raw)

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

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  <jbeulich@novell.com>

	* 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



[-- Attachment #2: binutils-mainline-macro-label-leak.patch --]
[-- Type: text/plain, Size: 1351 bytes --]

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  <jbeulich@novell.com>

	* 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

             reply	other threads:[~2005-05-09 15:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-09 15:21 Jan Beulich [this message]
2005-05-09 23:39 ` Alan Modra

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=s27f8dc4.034@emea1-mh.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=binutils@sources.redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).