[PATCH] gas/read.c memory leak fix

Elias Athanasopoulos eathan@otenet.gr
Tue Jun 11 11:30:00 GMT 2002


Hi,

I tested it, but I'm not quite sure if it is safe. At least 
register_dependency() uses xstrdup() to duplicate the path, but 
input_scrub_insert_file() eventually calls input_scrub_new_file().

Elias

gas/ChangeLog

2002-06-11  Elias Athanasopoulos  <eathan@otenet.gr>

	* read.c (s_include): Fix memory leak.	

	
--- read.c.orig	Tue Jun 11 20:42:03 2002
+++ read.c	Tue Jun 11 21:29:18 2002
@@ -5121,16 +5121,17 @@
       if (0 != (try = fopen (path, FOPEN_RT)))
 	{
 	  fclose (try);
-	  goto gotit;
+	  register_dependency (path);
+	  input_scrub_insert_file (path);
+	  free (path);
+	  return;
 	}
     }
 
   free (path);
-  path = filename;
-gotit:
-  /* malloc Storage leak when file is found on path.  FIXME-SOMEDAY.  */
-  register_dependency (path);
-  input_scrub_insert_file (path);   
+
+  register_dependency (filename);
+  input_scrub_insert_file (filename);   
 }
 
 void




More information about the Binutils mailing list