Skip to content

Commit 39dc6d2

Browse files
committed
Check projectM and playlist handles after creation
Fail in a "good" manner instead of performing unchecked null pointer dereferences in later API calls.
1 parent ec2aeff commit 39dc6d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/ProjectMWrapper.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ void ProjectMWrapper::initialize(Poco::Util::Application& app)
3636
auto texturePaths = GetPathListWithDefault("texturePath", app.config().getString("", ""));
3737

3838
_projectM = projectm_create();
39+
if (!_projectM)
40+
{
41+
poco_error(_logger, "Failed to initialize projectM. Possible reasons are a lack of required OpenGL features or GPU resources.");
42+
throw std::runtime_error("projectM initialization failed");
43+
}
3944

4045
int fps = _projectMConfigView->getInt("fps", 60);
4146
if (fps <= 0)
@@ -72,6 +77,12 @@ void ProjectMWrapper::initialize(Poco::Util::Application& app)
7277

7378
// Playlist
7479
_playlist = projectm_playlist_create(_projectM);
80+
if (!_playlist)
81+
{
82+
83+
poco_error(_logger, "Failed to create the projectM preset playlist manager instance.");
84+
throw std::runtime_error("Playlist initialization failed");
85+
}
7586

7687
projectm_playlist_set_shuffle(_playlist, _projectMConfigView->getBool("shuffleEnabled", true));
7788

0 commit comments

Comments
 (0)