code: Throw an error on nullptr for util::library::load

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2023-09-03 12:09:57 +02:00 committed by Xaymar
parent 50c85608c3
commit 25ba51df12

View file

@ -102,6 +102,10 @@ std::shared_ptr<::streamfx::util::library> streamfx::util::library::load(std::st
std::shared_ptr<::streamfx::util::library> streamfx::util::library::load(obs_module_t* instance) std::shared_ptr<::streamfx::util::library> streamfx::util::library::load(obs_module_t* instance)
{ {
if (!instance) {
throw std::runtime_error("Can't load nullptr as a library.");
}
// Get an absolute path to the module. // Get an absolute path to the module.
auto path = std::filesystem::absolute(std::filesystem::u8path(obs_get_module_binary_path(instance))); auto path = std::filesystem::absolute(std::filesystem::u8path(obs_get_module_binary_path(instance)));