Fix for [Bug preprocessor/16366] Preprocessor option -remap causes memory corruption

Andris Pavenis pavenis@latnet.lv
Tue Jul 6 08:09:00 GMT 2004


Use of preprocessor option -remap causes memory corruption for 
gcc-3.4.1 and HEAD branch

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16366

Here is a patch which fixes it for HEAD. Patch for gcc-3.4.1 is in bug 
report

2004-07-06  Andris Pavenis <pavenis@latnet.lv>

	* files.c (_cpp_find_file): fix memory corruption when -remap
	 is specified


Index: libcpp/files.c
===================================================================
RCS file: /cvs/gcc/gcc/libcpp/files.c,v
retrieving revision 1.4
diff -p -r1.4 files.c
*** libcpp/files.c	26 Jun 2004 17:39:40 -0000	1.4
--- libcpp/files.c	6 Jul 2004 07:36:17 -0000
*************** _cpp_find_file (cpp_reader *pfile, const
*** 484,489 ****
--- 484,495 ----
      }
  
   found:
+   /* pfile->file_hash may have been modified if -remap is specified  */
+   if (CPP_OPTION (pfile, remap))
+     hash_slot = (struct file_hash_entry **)
+        htab_find_slot_with_hash (pfile->file_hash, fname,
+   			         htab_hash_string (fname),
+ 			         INSERT);
    /* Store this new result in the hash table.  */
    entry = new_file_hash_entry (pfile);
    entry->next = *hash_slot;



More information about the Gcc-patches mailing list