This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gas/read.c memory leak fix


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]