all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dired.c fails to gc protect lisp object (patch included)
@ 2007-03-11 23:53 Rich Felker
  2007-03-12  4:24 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2007-03-11 23:53 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

i was experiencing random crashes because file_name_completion (in
dired.c) does not protect the "name" object from garbage collection.
the attached patch seems to fix it.

i'm using emacs-unicode-2 but this might apply to other versions as
well.

~rich felker


[-- Attachment #2: dired-gcpro.diff --]
[-- Type: text/plain, Size: 1141 bytes --]

Index: dired.c
===================================================================
RCS file: /sources/emacs/emacs/src/dired.c,v
retrieving revision 1.104.4.17
diff -u -r1.104.4.17 dired.c
--- dired.c	26 Jan 2007 06:15:08 -0000	1.104.4.17
+++ dired.c	11 Mar 2007 23:39:11 -0000
@@ -521,6 +521,7 @@
   for (passcount = !!all_flag; NILP (bestmatch) && passcount < 2; passcount++)
     {
       int inner_count = SPECPDL_INDEX ();
+      struct gcpro gcpro1;
 
       BLOCK_INPUT;
       d = opendir (SDATA (Fdirectory_file_name (encoded_dir)));
@@ -665,6 +666,7 @@
 	    }
 	  else
 	    name = make_string (dp->d_name, len);
+	  GCPRO1(name);
 
 	  /* Test the predicate, if any.  */
 
@@ -673,7 +675,10 @@
 	      Lisp_Object decoded;
 	      decoded = Fexpand_file_name (DECODE_FILE (name), dirname);
 	      if (NILP (call1 (predicate, decoded)))
-		continue;
+		{
+		  UNGCPRO;
+		  continue;
+		}
 	    }
 
 	  /* Suitably record this match.  */
@@ -736,6 +741,7 @@
 		matchsize++;
 	      bestmatchsize = matchsize;
 	    }
+	  UNGCPRO;
 	}
       /* This closes the directory.  */
       bestmatch = unbind_to (inner_count, bestmatch);

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-12  4:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-11 23:53 dired.c fails to gc protect lisp object (patch included) Rich Felker
2007-03-12  4:24 ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.