[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

cooledit segfault on powerpc (was Re: Help with #123015 on cooledit)



At 18:16 -0600 28 Dec 2001, Colin Watson <cjwatson@debian.org> wrote:
> Does anyone have time to dig into bug #123015 a little? I've tried the
> obvious fix (make sure the built-in CRASHES_ON_STARTUP workaround is
> defined :)), but Mark Brown says that doesn't help. The only unstable

Another occurrence of reusing a va_list variable.  Although in this
case, it looks like it was just an oversight.  In addition to fixing
this one occurrence, I checked the other places that use va_list
variables, and they all seem to be correct.  But, during that
inspection, I did find a couple of other unrelated errors which are also
fixed in the patch.

The patch also applies to the latest upstream version, so I'm CC'ing the
upstream author.

--- widget/stringtools.c.dist	Sat Dec 29 03:37:12 2001
+++ widget/stringtools.c	Sat Dec 29 03:39:15 2001
@@ -516,6 +516,14 @@
 {
     char *s;
     size_t l;
+
+#ifdef __va_copy
+    va_list va_save;
+    __va_copy (va_save, ap);
+#else
+#define va_save ap
+#endif /* defined __va_copy */
+
 #ifdef HAVE_MAD
     s = mad_alloc ((l = vfmtlen (fmt, ap)) + 1, file, line);
 #else
@@ -525,7 +533,7 @@
 /* NLS ? */
 	fprintf (stderr, "cooledit:%s:%d: malloc return zero\n", __FILE__, __LINE__);
     s[l] = 0;
-    vsprintf (s, fmt, ap);
+    vsprintf (s, fmt, va_save);
     if (s[l]
 #ifdef DEBUG_VFMTLEN
      || strlen (s) != l
--- widget/editcmd.c.dist	Sat Dec 29 03:28:34 2001
+++ widget/editcmd.c	Sat Dec 29 03:29:02 2001
@@ -2829,7 +2829,7 @@
     va_list pa;
     char s[1024];
     va_start (pa, fmt);
-    sprintf (s, fmt, pa);
+    vsprintf (s, fmt, pa);
     i = edit_print_string (e, s);
     va_end (pa);
     return i;
--- widget/coolwidget.c.dist	Sat Dec 29 03:23:00 2001
+++ widget/coolwidget.c	Sat Dec 29 03:24:10 2001
@@ -34,6 +34,7 @@
     char *str;
     va_start (s, fmt);
     str = vsprintf_alloc (catstrs (" ", fmt, " ", 0), s);
+    va_end (s);
     CFatalErrorDialog (20, 20, str);
     free (str);
 }

-- 
Aaron Schrab     aaron@schrab.com      http://www.execpc.com/~aarons/
 Beware of bugs in the above code; I have only proved it correct, not
 tried it.  -- Donald Knuth



Reply to: