提交 26d3f42b 编写于 作者: W wangrui05

libobs: Fix heap corruption in obs_source_output_video

上级 7bc443b3
...@@ -2342,7 +2342,7 @@ static void clean_cache(obs_source_t *source) ...@@ -2342,7 +2342,7 @@ static void clean_cache(obs_source_t *source)
} }
#define MAX_ASYNC_FRAMES 30 #define MAX_ASYNC_FRAMES 30
//if return value is not null then do (os_atomic_dec_long(&output->refs) == 0) && obs_source_frame_destroy(output)
static inline struct obs_source_frame *cache_video(struct obs_source *source, static inline struct obs_source_frame *cache_video(struct obs_source *source,
const struct obs_source_frame *frame) const struct obs_source_frame *frame)
{ {
...@@ -2399,11 +2399,6 @@ static inline struct obs_source_frame *cache_video(struct obs_source *source, ...@@ -2399,11 +2399,6 @@ static inline struct obs_source_frame *cache_video(struct obs_source *source,
copy_frame_data(new_frame, frame); copy_frame_data(new_frame, frame);
if (os_atomic_dec_long(&new_frame->refs) == 0) {
obs_source_frame_destroy(new_frame);
new_frame = NULL;
}
return new_frame; return new_frame;
} }
...@@ -2422,13 +2417,17 @@ void obs_source_output_video(obs_source_t *source, ...@@ -2422,13 +2417,17 @@ void obs_source_output_video(obs_source_t *source,
cache_video(source, frame) : NULL; cache_video(source, frame) : NULL;
/* ------------------------------------------- */ /* ------------------------------------------- */
pthread_mutex_lock(&source->async_mutex);
if (output) { if (output) {
pthread_mutex_lock(&source->async_mutex); if (os_atomic_dec_long(&output->refs) == 0) {
da_push_back(source->async_frames, &output); obs_source_frame_destroy(output);
pthread_mutex_unlock(&source->async_mutex); output = NULL;
source->async_active = true; } else {
da_push_back(source->async_frames, &output);
source->async_active = true;
}
} }
pthread_mutex_unlock(&source->async_mutex);
} }
static inline bool preload_frame_changed(obs_source_t *source, static inline bool preload_frame_changed(obs_source_t *source,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册