Fixed bug 3723 - Possible double free in kmsdrm init code on certain errors
authorSam Lantinga <slouken@libsdl.org>
Fri, 11 Aug 2017 10:05:45 -0700
changeset 11217d9c3f934bd0e
parent 11216 908e4fe53f5a
child 11218 0060bcf673e8
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.
src/video/kmsdrm/SDL_kmsdrmvideo.c
     1.1 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c	Thu Aug 10 11:57:19 2017 -0700
     1.2 +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c	Fri Aug 11 10:05:45 2017 -0700
     1.3 @@ -325,6 +325,7 @@
     1.4          }
     1.5  
     1.6          KMSDRM_drmModeFreeConnector(connector);
     1.7 +        connector = NULL;
     1.8      }
     1.9  
    1.10      if (i == resources->count_connectors) {
    1.11 @@ -345,6 +346,7 @@
    1.12          }
    1.13  
    1.14          KMSDRM_drmModeFreeEncoder(encoder);
    1.15 +        encoder = NULL;
    1.16      }
    1.17  
    1.18      if (i == resources->count_encoders) {