]> git.sesse.net Git - mlt/commitdiff
mlt_property_get_time(): get mutex before accessing self->types
authorMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 25 Jul 2012 18:43:44 +0000 (20:43 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 25 Jul 2012 22:17:56 +0000 (00:17 +0200)
Fixes Coverity CID 709356: Data race condition (MISSING_LOCK)
Accessing variable "self->types" (mlt_property_s.types) requires the mlt_property_s.mutex lock.
871                self->types |= mlt_prop_string;

src/framework/mlt_property.c

index 7a518ff443598d2977e02e7a05ee1a48f78b1d0b..4d5f57c7c53ed84c1c7acadc77e90e6c0beaf796 100644 (file)
@@ -864,6 +864,11 @@ char *mlt_property_get_time( mlt_property self, mlt_time_format format, double f
                // Set the new locale
                setlocale( LC_NUMERIC, localename );
        }
+       else
+       {
+               // Make sure we have a lock before accessing self->types
+               pthread_mutex_lock( &self->mutex );
+       }
 
        // Convert number to string
        if ( self->types & mlt_prop_int )
@@ -910,6 +915,11 @@ char *mlt_property_get_time( mlt_property self, mlt_time_format format, double f
                free( orig_localename );
                pthread_mutex_unlock( &self->mutex );
        }
+       else
+       {
+               // Make sure we have a lock before accessing self->types
+               pthread_mutex_unlock( &self->mutex );
+       }
 
        // Return the string (may be NULL)
        return self->prop_string;