Browse Source

obs-ffmpeg: Fix a crash with invalid URL

This fixes a crash when an invalid URL is used.

Signed-off-by: pkv <[email protected]>
pkv 4 months ago
parent
commit
467967eab6
2 changed files with 12 additions and 1 deletions
  1. 11 1
      plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c
  2. 1 0
      plugins/obs-ffmpeg/obs-ffmpeg-output.h

+ 11 - 1
plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c

@@ -341,11 +341,21 @@ static inline int connect_mpegts_url(struct ffmpeg_output *stream, bool is_rist)
 
 	if (err < 0)
 		goto fail;
+	else
+		stream->has_connected = true;
 
 	return 0;
 fail:
-	if (uc)
+	stream->has_connected = false;
+
+	if (uc) {
+		if (is_rist)
+			librist_close(uc);
+		else
+			libsrt_close(uc);
 		av_freep(&uc->priv_data);
+	}
+
 	av_freep(&uc);
 #if HAVE_WINSOCK2_H
 	WSACleanup();

+ 1 - 0
plugins/obs-ffmpeg/obs-ffmpeg-output.h

@@ -120,6 +120,7 @@ struct ffmpeg_output {
 	pthread_t start_stop_thread;
 	pthread_mutex_t start_stop_mutex;
 	volatile bool start_stop_thread_active;
+	bool has_connected;
 #endif
 };