Browse Source

frontend: Prevent creation of scene collections with empty name

Empty names for scene collections are not allowed, but this constraint
is only enforced by UI code during text input.

Thus frontend API users are able to create valid scene collections with
empty names which will lead to later possible crashes as the scene
collection is malformed.

As the frontend API uses the related function CreateNewSceneCollection
which handles exceptions by this method, no crashes should occur when
an empty string is provided by an API caller.
PatTheMav 9 months ago
parent
commit
552c19cab2
1 changed files with 4 additions and 0 deletions
  1. 4 0
      frontend/widgets/OBSBasic_SceneCollections.cpp

+ 4 - 0
frontend/widgets/OBSBasic_SceneCollections.cpp

@@ -83,6 +83,10 @@ void cleanBackupCollision(const OBSSceneCollection &collection)
 
 void OBSBasic::SetupNewSceneCollection(const std::string &collectionName)
 {
+	if (collectionName.empty()) {
+		throw std::logic_error("Cannot create new scene collection with empty collection name");
+	}
+
 	const OBSSceneCollection &newCollection = CreateSceneCollection(collectionName);
 
 	OnEvent(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING);