diff src/tests.c @ 5156:6bff4f219697

fix crash etc. in tests.c/c-tests.el -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * tests.c: * tests.c (Ftest_data_format_conversion): Need to GCPRO newly created objects or we'll eventually get a crash due to occurrence of call2(). tests/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * automated/c-tests.el: * automated/c-tests.el (when): Use `with-temp-buffer' so results don't get written into source file.
author Ben Wing <ben@xemacs.org>
date Thu, 18 Mar 2010 10:19:08 -0500
parents e70a73f9243d
children 71ee43b8a74d
line wrap: on
line diff
--- a/src/tests.c	Thu Mar 18 10:17:13 2010 -0500
+++ b/src/tests.c	Thu Mar 18 10:19:08 2010 -0500
@@ -49,7 +49,7 @@
        ())
 {
   void *ptr; Bytecount len;
-  Lisp_Object string, opaque, conversion_result = Qnil;
+  Lisp_Object string = Qnil, opaque = Qnil, conversion_result = Qnil;
 
   Ibyte int_foo[] = "\n\nfoo\nbar";
   Extbyte ext_unix[]= "\n\nfoo\nbar";
@@ -72,6 +72,20 @@
   Lisp_Object string_latin1 = make_string (int_latin1, sizeof (int_latin1) - 1);
   int autodetect_eol_p =
     !NILP (Fsymbol_value (intern ("eol-detection-enabled-p")));
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+  struct gcpro ngcpro1, ngcpro2, ngcpro3;
+#ifdef MULE
+  struct gcpro ngcpro4;
+#endif
+
+  /* DFC conversion inhibits GC, but we have a call2() below which calls
+     Lisp, which can trigger GC, so we need to GC-protect everything here. */
+  GCPRO5 (string, opaque, conversion_result, opaque_dos, string_foo);
+#ifdef MULE
+  NGCPRO4 (string_latin2, opaque_latin, opaque0_latin, string_latin1);
+#else
+  NGCPRO3 (opaque_latin, opaque0_latin, string_latin1);
+#endif
 
   /* Check for expected strings before and after conversion.
      Conversions depend on whether MULE is defined. */
@@ -541,6 +555,8 @@
 		      Qbinary);
   DFC_CHECK_DATA (ptr, len, ext_dos, "DOS Lisp opaque, ALLOCA, binary");
 
+  NUNGCPRO;
+  UNGCPRO;
   return conversion_result;
 }