mirror of https://github.com/libsdl-org/SDL.git
events: Fix undefined behavior when disabling some event types
Shifting a signed int left by 31 is UB.
(cherry picked from commit 15fd3fcdc2)
This commit is contained in:
parent
f46ef5d76d
commit
24ccde693e
|
|
@ -1318,7 +1318,7 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||||
Uint8 lo = (type & 0xff);
|
Uint8 lo = (type & 0xff);
|
||||||
|
|
||||||
if (SDL_disabled_events[hi] &&
|
if (SDL_disabled_events[hi] &&
|
||||||
(SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) {
|
(SDL_disabled_events[hi]->bits[lo / 32] & (1U << (lo & 31)))) {
|
||||||
current_state = SDL_DISABLE;
|
current_state = SDL_DISABLE;
|
||||||
} else {
|
} else {
|
||||||
current_state = SDL_ENABLE;
|
current_state = SDL_ENABLE;
|
||||||
|
|
@ -1332,11 +1332,11 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||||
}
|
}
|
||||||
/* Out of memory, nothing we can do... */
|
/* Out of memory, nothing we can do... */
|
||||||
if (SDL_disabled_events[hi]) {
|
if (SDL_disabled_events[hi]) {
|
||||||
SDL_disabled_events[hi]->bits[lo / 32] |= (1 << (lo & 31));
|
SDL_disabled_events[hi]->bits[lo / 32] |= (1U << (lo & 31));
|
||||||
SDL_FlushEvent(type);
|
SDL_FlushEvent(type);
|
||||||
}
|
}
|
||||||
} else { // state == SDL_ENABLE
|
} else { // state == SDL_ENABLE
|
||||||
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31));
|
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1U << (lo & 31));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SDL_JOYSTICK_DISABLED
|
#ifndef SDL_JOYSTICK_DISABLED
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue