You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavf/fifo: fix undefined behaviour in deinit when destroying mutex
Reviewed-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
@@ -73,6 +73,7 @@ typedef struct FifoContext {
|
|||||||
int restart_with_keyframe;
|
int restart_with_keyframe;
|
||||||
|
|
||||||
pthread_mutex_t overflow_flag_lock;
|
pthread_mutex_t overflow_flag_lock;
|
||||||
|
int overflow_flag_lock_initialized;
|
||||||
/* Value > 0 signals queue overflow */
|
/* Value > 0 signals queue overflow */
|
||||||
volatile uint8_t overflow_flag;
|
volatile uint8_t overflow_flag;
|
||||||
|
|
||||||
@@ -515,6 +516,7 @@ static int fifo_init(AVFormatContext *avf)
|
|||||||
ret = pthread_mutex_init(&fifo->overflow_flag_lock, NULL);
|
ret = pthread_mutex_init(&fifo->overflow_flag_lock, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return AVERROR(ret);
|
return AVERROR(ret);
|
||||||
|
fifo->overflow_flag_lock_initialized = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -601,6 +603,7 @@ static void fifo_deinit(AVFormatContext *avf)
|
|||||||
av_dict_free(&fifo->format_options);
|
av_dict_free(&fifo->format_options);
|
||||||
avformat_free_context(fifo->avf);
|
avformat_free_context(fifo->avf);
|
||||||
av_thread_message_queue_free(&fifo->queue);
|
av_thread_message_queue_free(&fifo->queue);
|
||||||
|
if (fifo->overflow_flag_lock_initialized)
|
||||||
pthread_mutex_destroy(&fifo->overflow_flag_lock);
|
pthread_mutex_destroy(&fifo->overflow_flag_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user