Browse Source

obs-ffmpeg: Fix crash on failed audio codec init (for real)

Richard Stanway 6 years ago
parent
commit
460c34aeaf
1 changed files with 4 additions and 3 deletions
  1. 4 3
      plugins/obs-ffmpeg/obs-ffmpeg-output.c

+ 4 - 3
plugins/obs-ffmpeg/obs-ffmpeg-output.c

@@ -474,11 +474,12 @@ static void close_audio(struct ffmpeg_data *data)
 		for (size_t i = 0; i < MAX_AV_PLANES; i++)
 			circlebuf_free(&data->excess_frames[idx][i]);
 
-		av_freep(&data->samples[idx][0]);
-		if (data->audio_streams[idx]) {
+		if (data->samples[idx][0])
+			av_freep(&data->samples[idx][0]);
+		if (data->audio_streams[idx])
 			avcodec_close(data->audio_streams[idx]->codec);
+		if (data->aframe[idx])
 			av_frame_free(&data->aframe[idx]);
-		}
 	}
 }