Преглед на файлове

video: Fix memory leak when deleting a video display

The display deletion code would not free the driver data or name if the display index was the last, or only one, in the list.

(cherry picked from commit 20f1061cc86b07146ba410e551d4994cd430e209)
Frank Praznik преди 1 година
родител
ревизия
0f5752b0fc
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      src/video/SDL_video.c

+ 2 - 2
src/video/SDL_video.c

@@ -672,9 +672,9 @@ void SDL_DelVideoDisplay(int index)
 
     SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_DISCONNECTED, 0);
 
+    SDL_free(_this->displays[index].driverdata);
+    SDL_free(_this->displays[index].name);
     if (index < (_this->num_displays - 1)) {
-        SDL_free(_this->displays[index].driverdata);
-        SDL_free(_this->displays[index].name);
         SDL_memmove(&_this->displays[index], &_this->displays[index + 1], (_this->num_displays - index - 1) * sizeof(_this->displays[index]));
     }
     --_this->num_displays;