[Mlt-devel] [PATCH 7/8] mlt_property_get_time(): get mutex before accessing self->types
Brought to you by:
ddennedy,
lilo_booter
From: Mikko R. <mik...@ik...> - 2012-07-25 22:30:17
|
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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/framework/mlt_property.c b/src/framework/mlt_property.c index 7a518ff..4d5f57c 100644 --- a/src/framework/mlt_property.c +++ b/src/framework/mlt_property.c @@ -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; -- 1.7.10.4 |