VirtualBox

Changeset 34513 in vbox for trunk/src


Ignore:
Timestamp:
Nov 30, 2010 1:35:16 PM (14 years ago)
Author:
vboxsync
Message:

Frontends/VBoxSDL: fix SDL uninit code, in certain failure cases it can be called without being completely initialized and that could result in a crash

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp

    r31698 r34513  
    66
    77/*
    8  * Copyright (C) 2006-2007 Oracle Corporation
     8 * Copyright (C) 2006-2010 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6767#endif /* VBOX_SECURELABEL */
    6868
    69 static SDL_Surface *gWMIcon;                    /**< the application icon */
    70 static RTNATIVETHREAD gSdlNativeThread;         /**< the SDL thread */
     69static bool gfSdlInitialized = false;           /**< if SDL was initialized */
     70static SDL_Surface *gWMIcon = NULL;             /**< the application icon */
     71static RTNATIVETHREAD gSdlNativeThread = NIL_RTNATIVETHREAD; /**< the SDL thread */
    7172
    7273//
     
    185186        return false;
    186187    }
     188    gfSdlInitialized = true;
    187189
    188190    const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
     
    240242void VBoxSDLFB::uninit()
    241243{
    242     AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
    243     SDL_QuitSubSystem(SDL_INIT_VIDEO);
    244     if (gWMIcon)
    245     {
    246         SDL_FreeSurface(gWMIcon);
    247         gWMIcon = NULL;
     244    if (gfSdlInitialized)
     245    {
     246        AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
     247        SDL_QuitSubSystem(SDL_INIT_VIDEO);
     248        if (gWMIcon)
     249        {
     250            SDL_FreeSurface(gWMIcon);
     251            gWMIcon = NULL;
     252        }
    248253    }
    249254}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette