Skip to content

Commit 6755ad7

Browse files
authored
[kdenlivetitle] Fix uninitialized mutex (#1234)
On Unix this is also wrong, but not fatal. However with pthread4w on MSVC locking and unlocking an uninitialized mutex crashes.
1 parent 36995f1 commit 6755ad7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/modules/qt/producer_kdenlivetitle.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ static int producer_get_frame(mlt_producer producer, mlt_frame_ptr frame, int in
186186
static void producer_close(mlt_producer producer)
187187
{
188188
producer_ktitle self = producer->child;
189+
pthread_mutex_destroy(&self->mutex);
189190
producer->close = NULL;
190191
mlt_service_cache_purge(MLT_PRODUCER_SERVICE(producer));
191192
mlt_producer_close(producer);
@@ -202,8 +203,17 @@ mlt_producer producer_kdenlivetitle_init(mlt_profile profile,
202203
producer_ktitle self = calloc(1, sizeof(struct producer_ktitle_s));
203204
if (self != NULL && mlt_producer_init(&self->parent, self) == 0) {
204205
mlt_producer producer = &self->parent;
206+
205207
/* Get the properties interface */
206208
mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer);
209+
210+
/* Initialize the mutex */
211+
if (pthread_mutex_init(&self->mutex, NULL) != 0) {
212+
mlt_producer_close(producer);
213+
free(self);
214+
return NULL;
215+
}
216+
207217
/* Callback registration */
208218
producer->get_frame = producer_get_frame;
209219
producer->close = (mlt_destructor) producer_close;

0 commit comments

Comments
 (0)