public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gas: buffer_and_nest() needs to pass nul-terminated string to temp_ilp()
@ 2023-02-14 15:53 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-02-14 15:53 UTC (permalink / raw)
  To: Binutils; +Cc: Nick Clifton

In 7545aa2dd2eb ("gas: improve interaction between read_a_source_file()
and s_linefile()") I didn't pay attention to the dual purpose of the
nul character previously used. This was to a fair degree because of the
open-coding of certain operations. Insert the earlier found line
terminator instead of a hard-coded newline, and do so early in this
special case (bypassing the later general insertion point). Plus
properly use sb_terminate() to mark the end of the string. (Note that
saved_eol_char was misnamed: Without calling sb_terminate() there's
simply random data at that position in the buffer.)

--- a/gas/macro.c
+++ b/gas/macro.c
@@ -263,13 +263,13 @@ buffer_and_nest (const char *from, const
 	  if (from != NULL && strcasecmp (from, "MACRO") == 0
 	      && len >= 8 && strncasecmp (ptr->ptr + i, "linefile", 8) == 0)
 	    {
-	      char saved_eol_char = ptr->ptr[ptr->len];
-
-	      ptr->ptr[ptr->len] = '\n';
-	      temp_ilp (ptr->ptr + i + 8);
+	      sb_add_char (ptr, more);
+	      temp_ilp (sb_terminate (ptr) + i + 8);
 	      s_linefile (0);
 	      restore_ilp ();
-	      ptr->ptr[ptr->len] = saved_eol_char;
+	      line_start = ptr->len;
+	      more = get_line (ptr);
+	      continue;
 	    }
 	}
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-14 15:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 15:53 [PATCH] gas: buffer_and_nest() needs to pass nul-terminated string to temp_ilp() Jan Beulich

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