• Paul Eggert's avatar
    Fix some crashes on self-modifying Elisp code · 93511e94
    Paul Eggert authored
    Prompted by a problem report by Alex in:
    http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00143.html
    * src/eval.c (For, Fprogn, Fsetq, FletX, eval_sub):
    Compute XCDR (x) near XCAR (x); although this doesn't fix any bugs,
    it is likely to run a bit faster with typical hardware caches.
    (Fif): Use Fcdr instead of XCDR, to avoid crashing on
    self-modifying S-expressions.
    (Fsetq, Flet, eval_sub): Count the number of arguments as we go
    instead of trusting an Flength prepass, to avoid problems when the
    code is self-modifying.
    (Fquote, Ffunction, Fdefvar, Fdefconst): Prefer !NILP to CONSP
    where either will do.  This is mostly to document the fact that
    the value must be a proper list.  It's also a tiny bit faster on
    typical machines nowadays.
    (Fdefconst, FletX): Prefer XCAR+XCDR to Fcar+Fcdr when either will do.
    (eval_sub): Check that the args are a list as opposed to some
    other object that has a length. This prevents e.g. (if . "string")
    from making Emacs dump core in some cases.
    * test/src/eval-tests.el (eval-tests--if-dot-string)
    (eval-tests--let-with-circular-defs, eval-tests--mutating-cond):
    New tests.
    93511e94
eval-tests.el 3.04 KB