GNU bug report logs - #6378
all-completions Segfault

Previous Next

Package: emacs;

Reported by: Nathan Weizenbaum <nex342 <at> gmail.com>

Date: Tue, 8 Jun 2010 15:48:02 UTC

Severity: normal

Done: Juanma Barranquero <lekktu <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lawrence Mitchell <wence <at> gmx.li>
To: bug-gnu-emacs <at> gnu.org
Subject: bug#6378: all-completions Segfault
Date: Tue, 08 Jun 2010 17:37:47 +0100
Nathan Weizenbaum wrote:
> This segfaults me on GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version
> 2.16.1) of 2010-05-09:

>   (all-completions "" [])

> I think the problem is on line 1593 of src/minibuf.c, but my
> Emacs-innards-fu isn't good enough to attempt a fix.

I think this patch should fix things

diff --git a/src/minibuf.c b/src/minibuf.c
index ad81bfd..1d93901 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1590,7 +1590,7 @@ with a space are ignored unless STRING itself starts with a space.  */)
   if (type == 2)
     {
       obsize = XVECTOR (collection)->size;
-      bucket = XVECTOR (collection)->contents[index];
+      bucket = obsize == 0 ? zero : XVECTOR (collection)->contents[index];
     }
 
   while (1)


Although I don't understand why the code-path for the vector
version can't be simplified as in the following patch, which also
fixes the problem AFAICT:

diff --git a/src/minibuf.c b/src/minibuf.c
index ad81bfd..c6aae27 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1610,22 +1610,14 @@ with a space are ignored unless STRING itself starts with a space.  */)
 	}
       else if (type == 2)
 	{
-	  if (!EQ (bucket, zero))
-	    {
-	      elt = bucket;
-	      eltstring = elt;
-	      if (XSYMBOL (bucket)->next)
-		XSETSYMBOL (bucket, XSYMBOL (bucket)->next);
-	      else
-		XSETFASTINT (bucket, 0);
-	    }
-	  else if (++index >= obsize)
-	    break;
-	  else
-	    {
-	      bucket = XVECTOR (collection)->contents[index];
-	      continue;
-	    }
+          if ( index < obsize )
+            {
+              elt = bucket;
+              eltstring = elt;
+              bucket = XVECTOR (collection)->contents[++index];
+            }
+          else
+            break;
 	}
       else /* if (type == 3) */
 	{

Cheers,
Lawrence
-- 
Lawrence Mitchell <wence <at> gmx.li>





This bug report was last modified 15 years and 48 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.