obs-ffmpeg, obs-outputs: Check return of obs_encoder_get_extra_data

A race condition can occur in obs-outputs where the send_thread is in
the process of (re)connecting but the encoder was shut down in the
meantime. This causes the expected header data to be garbage, resulting
in a crash.
This commit is contained in:
Richard Stanway
2022-06-19 23:08:06 +02:00
committed by Jim
parent 066f0defcf
commit 17c39ccb07
4 changed files with 14 additions and 7 deletions

View File

@@ -638,7 +638,8 @@ static bool send_audio_headers(struct ffmpeg_muxer *stream,
struct encoder_packet packet = {
.type = OBS_ENCODER_AUDIO, .timebase_den = 1, .track_idx = idx};
obs_encoder_get_extra_data(aencoder, &packet.data, &packet.size);
if (!obs_encoder_get_extra_data(aencoder, &packet.data, &packet.size))
return false;
return write_packet(stream, &packet);
}
@@ -649,7 +650,8 @@ static bool send_video_headers(struct ffmpeg_muxer *stream)
struct encoder_packet packet = {.type = OBS_ENCODER_VIDEO,
.timebase_den = 1};
obs_encoder_get_extra_data(vencoder, &packet.data, &packet.size);
if (!obs_encoder_get_extra_data(vencoder, &packet.data, &packet.size))
return false;
return write_packet(stream, &packet);
}