]> git.sesse.net Git - mlt/commitdiff
sdl/consumer_sdl_still.c: use mutex when changing sdl_screen
authorMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 1 Aug 2012 15:28:49 +0000 (17:28 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Mon, 6 Aug 2012 16:37:29 +0000 (18:37 +0200)
Fixes Coverity CID 709357: Data race condition (MISSING_LOCK)
Accessing variable "this->sdl_screen" (consumer_sdl_s.sdl_screen) requires the mlt_sdl_mutex lock.
230                this->sdl_screen = NULL;
...
Locking "mlt_sdl_mutex".
445                pthread_mutex_lock( &mlt_sdl_mutex );
consumer_sdl_s.sdl_screen is being accessed with lock "mlt_sdl_mutex" held.
446                this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
447                if ( consumer_get_dimensions( &this->window_width, &this->window_height ) )
448                        this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
449
450                uint32_t color = mlt_properties_get_int( this->properties, "window_background" );
451                if ( this->sdl_screen )
452                {
453                        SDL_FillRect( this->sdl_screen, NULL, color >> 8 );
454                        changed = 1;
455                }
456                pthread_mutex_unlock( &mlt_sdl_mutex );

src/modules/sdl/consumer_sdl_still.c

index 2b5ee6a6206bbcbb74c024d8fac7f43805d4ce8e..bc82ffa197e649794ab4ef83bc0b2e8aec03245b 100644 (file)
@@ -227,7 +227,9 @@ static int consumer_stop( mlt_consumer parent )
                        pthread_mutex_unlock( &mlt_sdl_mutex );
                }
 
+               pthread_mutex_lock( &mlt_sdl_mutex );
                this->sdl_screen = NULL;
+               pthread_mutex_unlock( &mlt_sdl_mutex );
        }
 
        return 0;