From 7f8ac8bf6f04045a676543862098c47bbf732f9e Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sun, 24 May 2026 11:51:38 +0000 Subject: 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. --- test/src/cmds-tests.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/src/cmds-tests.el b/test/src/cmds-tests.el index a02c36868ca..8c0e4706e3c 100644 --- a/test/src/cmds-tests.el +++ b/test/src/cmds-tests.el @@ -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 -- cgit v1.3