Add overflow check for INPUT_EVENT_POS_MIN
* src/keyboard.c (INPUT_EVENT_POS_MIN): Don’t assume (-1 - INPUT_EVENT_POS_MAX) fits into ptrdiff_t. This fixes a purely-theoretical problem that cannot occur on two’s-complement arithmetic. The Solaris 10 compiler still complains incorrectly, but oh well.
This commit is contained in:
parent
9076a631fe
commit
a1f603f0a3
1 changed files with 2 additions and 1 deletions
|
@ -3647,7 +3647,8 @@ kbd_buffer_unget_event (struct selection_input_event *event)
|
|||
#define INPUT_EVENT_POS_MAX \
|
||||
((ptrdiff_t) min (PTRDIFF_MAX, min (TYPE_MAXIMUM (Time) / 2, \
|
||||
MOST_POSITIVE_FIXNUM)))
|
||||
#define INPUT_EVENT_POS_MIN (-1 - INPUT_EVENT_POS_MAX)
|
||||
#define INPUT_EVENT_POS_MIN (PTRDIFF_MIN < -INPUT_EVENT_POS_MAX \
|
||||
? -1 - INPUT_EVENT_POS_MAX : PTRDIFF_MIN)
|
||||
|
||||
/* Return a Time that encodes position POS. POS must be in range. */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue