From: Thomas Jarosch
authorRyan C. Gordon <icculus@icculus.org>
Mon, 22 Dec 2003 01:21:20 +0000
changeset 75926ac9609211f
parent 758 619fc21d154e
child 760 cf9dd3aa6756
From: Thomas Jarosch
To: Ryan C. Gordon
Subject: SDL: DirectFB videodriver segfault
Date: Sun, 21 Dec 2003 20:40:14 +0100

Hi Ryan,

attached is a patch to fix a segfault in DirectFB_VideoQuit.
When SetVideoMode never gets called (f.e. wrong command line arguments
for "testsprite"), this->screen->hwdata is NULL.

Cheers,
Thomas
src/video/directfb/SDL_DirectFB_video.c
     1.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Thu Dec 18 05:01:47 2003 +0000
     1.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Mon Dec 22 01:21:20 2003 +0000
     1.3 @@ -1075,14 +1075,21 @@
     1.4  void DirectFB_VideoQuit(_THIS)
     1.5  {
     1.6    struct DirectFBEnumRect *rect    = enumlist;
     1.7 -  IDirectFBSurface        *surface = this->screen->hwdata->surface;
     1.8 -  IDirectFBPalette        *palette = this->screen->hwdata->palette;
     1.9  
    1.10 -  if (palette)
    1.11 -    palette->Release (palette);
    1.12 +  if (this->screen->hwdata)
    1.13 +    {
    1.14 +      IDirectFBSurface        *surface = this->screen->hwdata->surface;
    1.15 +      IDirectFBPalette        *palette = this->screen->hwdata->palette;
    1.16  
    1.17 -  if (surface)
    1.18 -    surface->Release (surface);
    1.19 +      if (palette)
    1.20 +        palette->Release (palette);
    1.21 +
    1.22 +      if (surface)
    1.23 +        surface->Release (surface);
    1.24 +
    1.25 +      this->screen->hwdata->surface = NULL;
    1.26 +      this->screen->hwdata->palette = NULL;
    1.27 +    }
    1.28  
    1.29    if (HIDDEN->c2frame)
    1.30      {