Skip to content

Commit

Permalink
feat(patchbay): check for has_pipewire to avoid segfault on user error
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Oct 14, 2023
1 parent 4e14a01 commit abc0b32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/patchbay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ namespace vencord
{
static std::unique_ptr<patchbay> instance;

if (!instance)
if (instance)
{
instance = std::unique_ptr<patchbay>(new patchbay);
return *instance;
}

return *instance;
if (!has_pipewire())
{
throw std::runtime_error("Not running PipeWire");
}

return *(instance = std::unique_ptr<patchbay>(new patchbay));
}

bool patchbay::has_pipewire()
Expand Down
2 changes: 1 addition & 1 deletion tests/node/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ catch (error)
console.warn("No PipeWire Server available");

assert(!venmic.PatchBay.hasPipeWire());
assert.throws(() => new venmic.PatchBay(), /failed to create patchbay/ig);
assert.throws(() => new venmic.PatchBay(), /(failed to create patchbay)|(not running pipewire)/ig);
}

0 comments on commit abc0b32

Please sign in to comment.