This is the mail archive of the mailing list for the GCC project.

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

Re: Patch: tiny cpplib bug

Laurynas Biveinis wrote:-

> But corresponding MMAP_THRESHOLD check is missing from purge_cache() and
> prevents cpp from compiling under DJGPP. Here is a fix:

Yes, thanks.  Actually, I want to add a bit more to your patch: it
appears that inc->mapped can not get initialised if a branch to
perror_fail occurs, which could cause nasty things to happen.

Committed under the obvious rule.


2000-09-16 Laurynas Biveinis <>

	* cppfiles.c (purge_cache): use munmap() only if MMAP_THRESHOLD
	(read_include_file): Ensure inc->mmaped is initialized.

Index: cppfiles.c
RCS file: /cvs/gcc/egcs/gcc/cppfiles.c,v
retrieving revision 1.79
diff -u -p -r1.79 cppfiles.c
--- cppfiles.c	2000/09/16 17:48:10	1.79
+++ cppfiles.c	2000/09/16 18:12:11
@@ -272,6 +272,7 @@ read_include_file (pfile, inc)
       size = inc->st.st_size;
+      inc->mapped = 0;
       if (pagesize == -1)
 	pagesize = getpagesize ();
@@ -300,7 +301,6 @@ read_include_file (pfile, inc)
 	      offset += count;
-	  inc->mapped = 0;
   else if (S_ISBLK (inc->st.st_mode))
@@ -363,9 +363,11 @@ purge_cache (inc)
   if (inc->buffer)
       if (inc->mapped)
 	munmap ((PTR) inc->buffer, inc->st.st_size);
 	free ((PTR) inc->buffer);
       inc->buffer = NULL;

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