From 552c19cab2e1c186bf7997b08a34b1568d0b6cf6 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Mon, 6 Jan 2025 18:48:11 +0100 Subject: [PATCH] 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. --- frontend/widgets/OBSBasic_SceneCollections.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/widgets/OBSBasic_SceneCollections.cpp b/frontend/widgets/OBSBasic_SceneCollections.cpp index 07c16cf6b..b49e149cf 100644 --- a/frontend/widgets/OBSBasic_SceneCollections.cpp +++ b/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);