Browse Source

obs-webrtc: Add null terminator to codec array

This fixes an issue where, when the MAX_CODECS length was equal to the
amount of supported codecs (3), it would leave the list without a null
terminator and crash when iterating over the elements.
John Bradley 1 year ago
parent
commit
627308bd53
2 changed files with 2 additions and 4 deletions
  1. 2 2
      plugins/obs-webrtc/whip-service.cpp
  2. 0 2
      plugins/obs-webrtc/whip-service.h

+ 2 - 2
plugins/obs-webrtc/whip-service.cpp

@@ -1,7 +1,7 @@
 #include "whip-service.h"
 
-const char *audio_codecs[MAX_CODECS] = {"opus"};
-const char *video_codecs[MAX_CODECS] = {"h264", "hevc", "av1"};
+const char *audio_codecs[] = {"opus", nullptr};
+const char *video_codecs[] = {"h264", "hevc", "av1", nullptr};
 
 WHIPService::WHIPService(obs_data_t *settings, obs_service_t *)
 	: server(),

+ 0 - 2
plugins/obs-webrtc/whip-service.h

@@ -2,8 +2,6 @@
 #include <obs-module.h>
 #include <string>
 
-#define MAX_CODECS 3
-
 struct WHIPService {
 	std::string server;
 	std::string bearer_token;