(init_eval): Use it to ensure handlerlist is non-NULL.
(unwind_to_catch): Make sure we never set handlerlist to NULL.
(Fsignal): Adjust NULLness test of handlerlist.
* src/lisp.h (PUSH_HANDLER): Assume handlerlist is non-NULL.
Fixes: debbugs:15802
+2013-11-05 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * eval.c (handlerlist_sentinel): New variable (bug#15802).
+ (init_eval): Use it to ensure handlerlist is non-NULL.
+ (unwind_to_catch): Make sure we never set handlerlist to NULL.
+ (Fsignal): Adjust NULLness test of handlerlist.
+
+ * lisp.h (PUSH_HANDLER): Assume handlerlist is non-NULL.
+
2013-11-05 Eli Zaretskii <eliz@gnu.org>
* callproc.c (call_process): Call prepare_to_modify_buffer before
Vrun_hooks = Qnil;
}
+static struct handler handlerlist_sentinel;
+
void
init_eval (void)
{
specpdl_ptr = specpdl;
- handlerlist = NULL;
+ { /* Put a dummy catcher at top-level so that handlerlist is never NULL.
+ This is important since handlerlist->nextfree holds the freelist
+ which would otherwise leak every time we unwind back to top-level. */
+ struct handler *c;
+ handlerlist = handlerlist_sentinel.nextfree = &handlerlist_sentinel;
+ PUSH_HANDLER (c, Qunbound, CATCHER);
+ eassert (c == &handlerlist_sentinel);
+ handlerlist_sentinel.nextfree = NULL;
+ handlerlist_sentinel.next = NULL;
+ }
Vquit_flag = Qnil;
debug_on_next_call = 0;
lisp_eval_depth = 0;
{
bool last_time;
+ eassert (catch->next);
+
/* Save the value in the tag. */
catch->val = value;
}
else
{
- if (handlerlist != 0)
+ if (handlerlist != &handlerlist_sentinel)
+ /* FIXME: This will come right back here if there's no `top-level'
+ catcher. A better solution would be to abort here, and instead
+ add a catch-all condition handler so we never come here. */
Fthrow (Qtop_level, Qt);
}
/* Fill in the components of c, and put it on the list. */
#define PUSH_HANDLER(c, tag_ch_val, handlertype) \
- if (handlerlist && handlerlist->nextfree) \
+ if (handlerlist->nextfree) \
(c) = handlerlist->nextfree; \
else \
{ \
(c) = xmalloc (sizeof (struct handler)); \
(c)->nextfree = NULL; \
- if (handlerlist) \
- handlerlist->nextfree = (c); \
+ handlerlist->nextfree = (c); \
} \
(c)->type = (handlertype); \
(c)->tag_or_ch = (tag_ch_val); \