bug#6214: 23.1; json-read-string crashes emacs with long string

Chong Yidong cyd at stupidchicken.com
Mon Aug 16 10:40:13 PDT 2010


Thanks, that is a useful backtrace.  Could you apply this patch and see
if it fixes the problem?


=== modified file 'src/eval.c'
*** src/eval.c	2010-08-06 19:07:16 +0000
--- src/eval.c	2010-08-16 17:37:22 +0000
***************
*** 2430,2437 ****
    register int i, numargs;
    register Lisp_Object spread_arg;
    register Lisp_Object *funcall_args;
!   Lisp_Object fun;
    struct gcpro gcpro1;
  
    fun = args [0];
    funcall_args = 0;
--- 2430,2438 ----
    register int i, numargs;
    register Lisp_Object spread_arg;
    register Lisp_Object *funcall_args;
!   Lisp_Object fun, retval;
    struct gcpro gcpro1;
+   USE_SAFE_ALLOCA;
  
    fun = args [0];
    funcall_args = 0;
***************
*** 2470,2477 ****
  	{
  	  /* Avoid making funcall cons up a yet another new vector of arguments
  	     by explicitly supplying nil's for optional values */
! 	  funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args)
! 						 * sizeof (Lisp_Object));
  	  for (i = numargs; i < XSUBR (fun)->max_args;)
  	    funcall_args[++i] = Qnil;
  	  GCPRO1 (*funcall_args);
--- 2471,2478 ----
  	{
  	  /* Avoid making funcall cons up a yet another new vector of arguments
  	     by explicitly supplying nil's for optional values */
! 	  SAFE_ALLOCA (funcall_args, Lisp_Object *, ((1 + XSUBR (fun)->max_args)
! 						     * sizeof (Lisp_Object)));
  	  for (i = numargs; i < XSUBR (fun)->max_args;)
  	    funcall_args[++i] = Qnil;
  	  GCPRO1 (*funcall_args);
***************
*** 2483,2490 ****
       function itself as well as its arguments.  */
    if (!funcall_args)
      {
!       funcall_args = (Lisp_Object *) alloca ((1 + numargs)
! 					     * sizeof (Lisp_Object));
        GCPRO1 (*funcall_args);
        gcpro1.nvars = 1 + numargs;
      }
--- 2484,2491 ----
       function itself as well as its arguments.  */
    if (!funcall_args)
      {
!       SAFE_ALLOCA (funcall_args, Lisp_Object *, ((1 + numargs)
! 						 * sizeof (Lisp_Object)));
        GCPRO1 (*funcall_args);
        gcpro1.nvars = 1 + numargs;
      }
***************
*** 2500,2506 ****
      }
  
    /* By convention, the caller needs to gcpro Ffuncall's args.  */
!   RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args));
  }
  
  /* Run hook variables in various ways.  */
--- 2501,2511 ----
      }
  
    /* By convention, the caller needs to gcpro Ffuncall's args.  */
!   retval = Ffuncall (gcpro1.nvars, funcall_args);
!   UNGCPRO;
!   SAFE_FREE ();
! 
!   return retval;
  }
  
  /* Run hook variables in various ways.  */



More information about the notmuch mailing list