diff options
| author | Paul Eggert | 2020-03-25 17:40:57 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-03-25 18:38:07 -0700 |
| commit | e4b6151ff119f36c64d3653b56f761fcdfe47fd3 (patch) | |
| tree | a1e0c516bb6fa75b46aed2e217b065c9fa9fb144 | |
| parent | d08c9472e821615da06f92756e49c271be8da7f1 (diff) | |
| download | emacs-e4b6151ff119f36c64d3653b56f761fcdfe47fd3.tar.gz emacs-e4b6151ff119f36c64d3653b56f761fcdfe47fd3.zip | |
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).
| -rw-r--r-- | lisp/subr.el | 6 | ||||
| -rw-r--r-- | 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'." | |||
| 1558 | 1558 | ||
| 1559 | ;;;; Obsolescent names for functions. | 1559 | ;;;; Obsolescent names for functions. |
| 1560 | 1560 | ||
| 1561 | (make-obsolete 'forward-point "use (+ (point) N) instead." "23.1") | ||
| 1562 | (make-obsolete 'buffer-has-markers-at nil "24.3") | 1561 | (make-obsolete 'buffer-has-markers-at nil "24.3") |
| 1563 | 1562 | ||
| 1564 | (make-obsolete 'invocation-directory "use the variable of the same name." | 1563 | (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'." | |||
| 1580 | (make-obsolete 'string-as-multibyte "use `decode-coding-string'." "26.1") | 1579 | (make-obsolete 'string-as-multibyte "use `decode-coding-string'." "26.1") |
| 1581 | (make-obsolete 'string-make-multibyte "use `decode-coding-string'." "26.1") | 1580 | (make-obsolete 'string-make-multibyte "use `decode-coding-string'." "26.1") |
| 1582 | 1581 | ||
| 1582 | (defun forward-point (n) | ||
| 1583 | "Return buffer position N characters after (before if N negative) point." | ||
| 1584 | (declare (obsolete "use (+ (point) N) instead." "23.1")) | ||
| 1585 | (+ (point) n)) | ||
| 1586 | |||
| 1583 | (defun log10 (x) | 1587 | (defun log10 (x) |
| 1584 | "Return (log X 10), the log base 10 of X." | 1588 | "Return (log X 10), the log base 10 of X." |
| 1585 | (declare (obsolete log "24.4")) | 1589 | (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 <https://www.gnu.org/licenses/>. */ | |||
| 31 | 31 | ||
| 32 | static int internal_self_insert (int, EMACS_INT); | 32 | static int internal_self_insert (int, EMACS_INT); |
| 33 | 33 | ||
| 34 | DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, | ||
| 35 | doc: /* Return buffer position N characters after (before if N negative) point. */) | ||
| 36 | (Lisp_Object n) | ||
| 37 | { | ||
| 38 | CHECK_FIXNUM (n); | ||
| 39 | |||
| 40 | return make_fixnum (PT + XFIXNUM (n)); | ||
| 41 | } | ||
| 42 | |||
| 43 | /* Add N to point; or subtract N if FORWARD is false. N defaults to 1. | 34 | /* Add N to point; or subtract N if FORWARD is false. N defaults to 1. |
| 44 | Validate the new location. Return nil. */ | 35 | Validate the new location. Return nil. */ |
| 45 | static Lisp_Object | 36 | static Lisp_Object |
| @@ -526,7 +517,6 @@ syms_of_cmds (void) | |||
| 526 | This is run after inserting the character. */); | 517 | This is run after inserting the character. */); |
| 527 | Vpost_self_insert_hook = Qnil; | 518 | Vpost_self_insert_hook = Qnil; |
| 528 | 519 | ||
| 529 | defsubr (&Sforward_point); | ||
| 530 | defsubr (&Sforward_char); | 520 | defsubr (&Sforward_char); |
| 531 | defsubr (&Sbackward_char); | 521 | defsubr (&Sbackward_char); |
| 532 | defsubr (&Sforward_line); | 522 | defsubr (&Sforward_line); |