Skip to content

Commit

Permalink
Fixed bug 4837 - Use after free in SDL_SensorUpdate (Thanks!)
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl committed Oct 23, 2019
1 parent 5025109 commit 3ac67cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sensor/SDL_sensor.c
Expand Up @@ -503,7 +503,7 @@ void
SDL_SensorUpdate(void)
{
int i;
SDL_Sensor *sensor;
SDL_Sensor *sensor, *next;

if (!SDL_WasInit(SDL_INIT_SENSOR)) {
return;
Expand Down Expand Up @@ -531,7 +531,8 @@ SDL_SensorUpdate(void)
SDL_updating_sensor = SDL_FALSE;

/* If any sensors were closed while updating, free them here */
for (sensor = SDL_sensors; sensor; sensor = sensor->next) {
for (sensor = SDL_sensors; sensor; sensor = next) {
next = sensor->next;
if (sensor->ref_count <= 0) {
SDL_SensorClose(sensor);
}
Expand Down

0 comments on commit 3ac67cf

Please sign in to comment.