]> git.sesse.net Git - mlt/commitdiff
sdl/consumer_sdl_preview.c: use mutex when changing refresh_count
authorMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 1 Aug 2012 15:21:51 +0000 (17:21 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Mon, 6 Aug 2012 16:37:28 +0000 (18:37 +0200)
Fixes Coverity CID 709360: Data race condition (MISSING_LOCK)

Locking "this->refresh_mutex".
133                pthread_mutex_lock( &this->refresh_mutex );
consumer_sdl_s.refresh_count is being accessed with lock "this->refresh_mutex" held.
134                this->refresh_count = this->refresh_count <= 0 ? 1 : this->refresh_count + 1;
135                pthread_cond_broadcast( &this->refresh_cond );
136                pthread_mutex_unlock( &this->refresh_mutex );
...
Accessing variable "this->refresh_count" (consumer_sdl_s.refresh_count) requires the consumer_sdl_s.refresh_mutex lock.
295        this->refresh_count = 0;
...
Locking "this->refresh_mutex".
445                                pthread_mutex_lock( &this->refresh_mutex );
446                                if ( this->running && speed == 0 && this->refresh_count <= 0 )
447                                {
448                                        mlt_events_fire( properties, "consumer-sdl-paused", NULL );
449                                        pthread_cond_wait( &this->refresh_cond, &this->refresh_mutex );
450                                }
consumer_sdl_s.refresh_count is being accessed with lock "this->refresh_mutex" held.
451                                this->refresh_count --;
452                                pthread_mutex_unlock( &this->refresh_mutex );

src/modules/sdl/consumer_sdl_preview.c

index 8bdde6a373cd14aa3118fc5ef39c757e4bdd6baa..5cd1059f4957e85fe2b38346c8ae66324a25b90b 100644 (file)
@@ -294,7 +294,9 @@ static void *consumer_thread( void *arg )
        // Determine if the application is dealing with the preview
        int preview_off = mlt_properties_get_int( properties, "preview_off" );
 
+       pthread_mutex_lock( &this->refresh_mutex );
        this->refresh_count = 0;
+       pthread_mutex_unlock( &this->refresh_mutex );
 
        // Loop until told not to
        while( this->running )