asan: double free sb_kill
authorAlan Modra <amodra@gmail.com>
Mon, 6 Jun 2022 04:57:17 +0000 (14:27 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 8 Jun 2022 06:52:15 +0000 (16:22 +0930)
oss-fuzz hits a flaky crash with a double-free.  I think this is due
to gas static state not being reinitialised between testcases, a bug
with oss-fuzz not gas.  Anyway, this patch should avoid the problem.

* input-scrub.c (input_scrub_push): Move init of sb_index..
(input_scrub_reinit): ..to here.

gas/input-scrub.c

index f65cd7957b1a050414e54bf0133ac27a04c6b082..ec0b007c77a1a8f0f7931d7e79c61882844b7971 100644 (file)
@@ -139,6 +139,7 @@ input_scrub_reinit (void)
   input_file_begin ();         /* Reinitialize! */
   logical_input_line = -1u;
   logical_input_file = NULL;
+  sb_index = -1;
 
   buffer_length = input_file_buffer_size () * 2;
   buffer_start = XNEWVEC (char, BEFORE_SIZE + AFTER_SIZE + 1 + buffer_length);
@@ -172,8 +173,6 @@ input_scrub_push (char *saved_position)
   saved->next_saved_file = next_saved_file;
   saved->input_file_save = input_file_push ();
 
-  sb_index = -1;
-
   input_scrub_reinit ();
 
   return saved;