瀏覽代碼

obs-outputs: Properly reset stream count on RTMP_Close

Every addStream call would increment this counter. After merging the
mbedTLS fixes, we no longer have extraneous RTMP_Init calls which were
masking the prescence of this bug. This caused every stream after the
first stream to have the wrong channel index, and eventually OBS would
crash due to an out of bounds write if the counter reached
RTMP_MAX_STREAMS.
Richard Stanway 5 年之前
父節點
當前提交
ee4cbb1199
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 3 3
      plugins/obs-outputs/librtmp/rtmp.c
  2. 2 0
      plugins/obs-outputs/rtmp-stream.c

+ 3 - 3
plugins/obs-outputs/librtmp/rtmp.c

@@ -4361,11 +4361,11 @@ RTMP_Close(RTMP *r)
             free(r->Link.streams[idx].playpath.av_val);
             r->Link.streams[idx].playpath.av_val = NULL;
         }
-
-        r->Link.curStreamIdx = 0;
-        r->Link.nStreams = 0;
     }
 
+    r->Link.curStreamIdx = 0;
+    r->Link.nStreams = 0;
+
     if ((r->Link.protocol & RTMP_FEATURE_WRITE) &&
             (r->Link.pFlags & RTMP_PUB_CLEAN) &&
             (r->Link.pFlags & RTMP_PUB_ALLOC))

+ 2 - 0
plugins/obs-outputs/rtmp-stream.c

@@ -407,6 +407,8 @@ static int send_packet(struct rtmp_stream *stream,
 	int recv_size = 0;
 	int ret = 0;
 
+	assert(idx < RTMP_MAX_STREAMS);
+
 	if (!stream->new_socket_loop) {
 #ifdef _WIN32
 		ret = ioctlsocket(stream->rtmp.m_sb.sb_socket, FIONREAD,