From e4b6151ff119f36c64d3653b56f761fcdfe47fd3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 25 Mar 2020 17:40:57 -0700 Subject: [PATCH] Fix integer overflow in forward-point * lisp/subr.el (forward-point): Rewrite in Lisp and move here ... * src/cmds.c (Fforward_point): ... from here. This fixes an integer overflow bug with (forward-point most-positive-fixnum). --- lisp/subr.el | 6 +++++- src/cmds.c | 10 ---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 123557e736b..70f33ee5bdb 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1558,7 +1558,6 @@ be a list of the form returned by `event-start' and `event-end'." ;;;; Obsolescent names for functions. -(make-obsolete 'forward-point "use (+ (point) N) instead." "23.1") (make-obsolete 'buffer-has-markers-at nil "24.3") (make-obsolete 'invocation-directory "use the variable of the same name." @@ -1580,6 +1579,11 @@ be a list of the form returned by `event-start' and `event-end'." (make-obsolete 'string-as-multibyte "use `decode-coding-string'." "26.1") (make-obsolete 'string-make-multibyte "use `decode-coding-string'." "26.1") +(defun forward-point (n) + "Return buffer position N characters after (before if N negative) point." + (declare (obsolete "use (+ (point) N) instead." "23.1")) + (+ (point) n)) + (defun log10 (x) "Return (log X 10), the log base 10 of X." (declare (obsolete log "24.4")) diff --git a/src/cmds.c b/src/cmds.c index 5d7a45e65f6..5b98a09fda9 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -31,15 +31,6 @@ along with GNU Emacs. If not, see . */ static int internal_self_insert (int, EMACS_INT); -DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, - doc: /* Return buffer position N characters after (before if N negative) point. */) - (Lisp_Object n) -{ - CHECK_FIXNUM (n); - - return make_fixnum (PT + XFIXNUM (n)); -} - /* Add N to point; or subtract N if FORWARD is false. N defaults to 1. Validate the new location. Return nil. */ static Lisp_Object @@ -526,7 +517,6 @@ syms_of_cmds (void) This is run after inserting the character. */); Vpost_self_insert_hook = Qnil; - defsubr (&Sforward_point); defsubr (&Sforward_char); defsubr (&Sbackward_char); defsubr (&Sforward_line); -- 2.39.2