mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Avoid crash in self-insert-command for peculiar arguments
* src/cmds.c (internal_self_insert): Don't call auto-fill-function after inserting zero newlines. * test/src/cmds-tests.el (self-insert-zero-newlines): New.
This commit is contained in:
parent
94dbab2fe4
commit
7f8ac8bf6f
2 changed files with 10 additions and 1 deletions
|
|
@ -477,7 +477,8 @@ internal_self_insert (int c, EMACS_INT n)
|
|||
if ((CHAR_TABLE_P (Vauto_fill_chars)
|
||||
? !NILP (CHAR_TABLE_REF (Vauto_fill_chars, c))
|
||||
: (c == ' ' || c == '\n'))
|
||||
&& !NILP (BVAR (current_buffer, auto_fill_function)))
|
||||
&& !NILP (BVAR (current_buffer, auto_fill_function))
|
||||
&& n > 0)
|
||||
{
|
||||
Lisp_Object auto_fill_result;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,5 +40,13 @@
|
|||
(let ((shortage (forward-line (+ 2 most-positive-fixnum))))
|
||||
(should (= shortage (1+ most-positive-fixnum))))))
|
||||
|
||||
(ert-deftest self-insert-zero-newlines ()
|
||||
"Test `self-insert-command' with arguments which used to cause a crash."
|
||||
(with-temp-buffer
|
||||
(let* ((pt nil)
|
||||
(auto-fill-function (lambda () (setq pt (point)))))
|
||||
(self-insert-command 0 10)
|
||||
(should-not (equal pt 0)))))
|
||||
|
||||
(provide 'cmds-tests)
|
||||
;;; cmds-tests.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue