diff options
| author | Paul Eggert | 2011-09-04 10:24:12 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-09-04 10:24:12 -0700 |
| commit | 3f8236f46ba78f807fa25a2b2db34d10730d51cc (patch) | |
| tree | 4502619093c6bba8d4497a3b0dfffc0581df7e64 | |
| parent | bc3200871917d5c54c8c4299a06bf8f8ba2ea02d (diff) | |
| download | emacs-3f8236f46ba78f807fa25a2b2db34d10730d51cc.tar.gz emacs-3f8236f46ba78f807fa25a2b2db34d10730d51cc.zip | |
* indent.c: Integer overflow fixes.
(position_indentation): Now takes ptrdiff_t, not int.
(Fvertical_motion): Don't wrap around LINES values that don't fit
in 'int'. Instead, treat them as extreme values. This is good
enough for windows, which can't have more than INT_MAX lines anyway.
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/indent.c | 12 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 6113c2362ee..9c5ca280eba 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-09-04 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * indent.c: Integer overflow fixes. | ||
| 4 | (position_indentation): Now takes ptrdiff_t, not int. | ||
| 5 | (Fvertical_motion): Don't wrap around LINES values that don't fit | ||
| 6 | in 'int'. Instead, treat them as extreme values. This is good | ||
| 7 | enough for windows, which can't have more than INT_MAX lines anyway. | ||
| 8 | |||
| 1 | 2011-09-03 Lars Magne Ingebrigtsen <larsi@gnus.org> | 9 | 2011-09-03 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 10 | ||
| 3 | * Require libxml/parser.h to avoid compilation warning. | 11 | * Require libxml/parser.h to avoid compilation warning. |
diff --git a/src/indent.c b/src/indent.c index 313315e9081..6e602d28f60 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -56,7 +56,7 @@ EMACS_INT last_known_column_point; | |||
| 56 | static int last_known_column_modified; | 56 | static int last_known_column_modified; |
| 57 | 57 | ||
| 58 | static EMACS_INT current_column_1 (void); | 58 | static EMACS_INT current_column_1 (void); |
| 59 | static EMACS_INT position_indentation (int); | 59 | static EMACS_INT position_indentation (ptrdiff_t); |
| 60 | 60 | ||
| 61 | /* Cache of beginning of line found by the last call of | 61 | /* Cache of beginning of line found by the last call of |
| 62 | current_column. */ | 62 | current_column. */ |
| @@ -855,7 +855,7 @@ following any initial whitespace. */) | |||
| 855 | } | 855 | } |
| 856 | 856 | ||
| 857 | static EMACS_INT | 857 | static EMACS_INT |
| 858 | position_indentation (register int pos_byte) | 858 | position_indentation (ptrdiff_t pos_byte) |
| 859 | { | 859 | { |
| 860 | register EMACS_INT column = 0; | 860 | register EMACS_INT column = 0; |
| 861 | int tab_width = SANE_TAB_WIDTH (current_buffer); | 861 | int tab_width = SANE_TAB_WIDTH (current_buffer); |
| @@ -2063,7 +2063,7 @@ whether or not it is currently displayed in some window. */) | |||
| 2063 | /* Do this even if LINES is 0, so that we move back to the | 2063 | /* Do this even if LINES is 0, so that we move back to the |
| 2064 | beginning of the current line as we ought. */ | 2064 | beginning of the current line as we ought. */ |
| 2065 | if (XINT (lines) == 0 || IT_CHARPOS (it) > 0) | 2065 | if (XINT (lines) == 0 || IT_CHARPOS (it) > 0) |
| 2066 | move_it_by_lines (&it, XINT (lines)); | 2066 | move_it_by_lines (&it, max (INT_MIN, XINT (lines))); |
| 2067 | } | 2067 | } |
| 2068 | else | 2068 | else |
| 2069 | { | 2069 | { |
| @@ -2083,7 +2083,7 @@ whether or not it is currently displayed in some window. */) | |||
| 2083 | && it.c == '\n')) | 2083 | && it.c == '\n')) |
| 2084 | move_it_by_lines (&it, -1); | 2084 | move_it_by_lines (&it, -1); |
| 2085 | it.vpos = 0; | 2085 | it.vpos = 0; |
| 2086 | move_it_by_lines (&it, XINT (lines)); | 2086 | move_it_by_lines (&it, min (INT_MAX, XINT (lines))); |
| 2087 | } | 2087 | } |
| 2088 | else | 2088 | else |
| 2089 | { | 2089 | { |
| @@ -2099,12 +2099,12 @@ whether or not it is currently displayed in some window. */) | |||
| 2099 | move_it_by_lines (&it, 1); | 2099 | move_it_by_lines (&it, 1); |
| 2100 | } | 2100 | } |
| 2101 | if (XINT (lines) > 1) | 2101 | if (XINT (lines) > 1) |
| 2102 | move_it_by_lines (&it, XINT (lines) - 1); | 2102 | move_it_by_lines (&it, min (INT_MAX, XINT (lines) - 1)); |
| 2103 | } | 2103 | } |
| 2104 | else | 2104 | else |
| 2105 | { | 2105 | { |
| 2106 | it.vpos = 0; | 2106 | it.vpos = 0; |
| 2107 | move_it_by_lines (&it, XINT (lines)); | 2107 | move_it_by_lines (&it, min (INT_MAX, XINT (lines))); |
| 2108 | } | 2108 | } |
| 2109 | } | 2109 | } |
| 2110 | } | 2110 | } |