mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-01 15:49:51 +08:00
libobs: Prevent encoders from initializing/starting if no media is set
This fixes a case of undefined behavior, where encoders can try to init or start without actually having any video_t or audio_t object assigned.
This commit is contained in:
@@ -443,6 +443,13 @@ static THREAD_LOCAL bool can_reroute = false;
|
||||
|
||||
static inline bool obs_encoder_initialize_internal(obs_encoder_t *encoder)
|
||||
{
|
||||
if (!encoder->media) {
|
||||
blog(LOG_ERROR,
|
||||
"obs_encoder_initialize_internal: encoder '%s' has no media set",
|
||||
encoder->context.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (encoder_active(encoder))
|
||||
return true;
|
||||
if (encoder->initialized)
|
||||
@@ -552,7 +559,7 @@ static inline void obs_encoder_start_internal(
|
||||
struct encoder_callback cb = {false, new_packet, param};
|
||||
bool first = false;
|
||||
|
||||
if (!encoder->context.data)
|
||||
if (!encoder->context.data || !encoder->media)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&encoder->callbacks_mutex);
|
||||
|
||||
Reference in New Issue
Block a user