Commit a05522a0893aa6a80467251f97aadab4543c8f48

Sam Lantinga 2017-08-11T10:05:45

Fixed bug 3723 - Possible double free in kmsdrm init code on certain errors Simon Hug KMSDRM_VideoInit allocates and frees some connectors and encoders but doesn't set the pointer to NULL after freeing. The cleanup code at the end may free one of those garbage pointer should an error happen in the initialization.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index ac75ec3..e7856ce 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -325,6 +325,7 @@ KMSDRM_VideoInit(_THIS)
         }
 
         KMSDRM_drmModeFreeConnector(connector);
+        connector = NULL;
     }
 
     if (i == resources->count_connectors) {
@@ -345,6 +346,7 @@ KMSDRM_VideoInit(_THIS)
         }
 
         KMSDRM_drmModeFreeEncoder(encoder);
+        encoder = NULL;
     }
 
     if (i == resources->count_encoders) {