From 15996cf9058ffd0b4d05ef56204b21e903bdd523 Mon Sep 17 00:00:00 2001 From: 0cyn Date: Wed, 15 Apr 2026 12:40:35 -0400 Subject: Improve nullptr checks across Extensions API --- pluginmanager.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'pluginmanager.cpp') diff --git a/pluginmanager.cpp b/pluginmanager.cpp index 3e61ea27..774e43d3 100644 --- a/pluginmanager.cpp +++ b/pluginmanager.cpp @@ -7,7 +7,7 @@ using namespace std; do \ { \ char* contents = (char*)(s); \ - string result(contents); \ + string result(contents ? contents : ""); \ BNFreeString(contents); \ return result; \ } while (0) @@ -387,10 +387,16 @@ bool RepositoryManager::AddRepository(const std::string& url, Ref RepositoryManager::GetRepositoryByPath(const std::string& repoPath) { - return new Repository(BNRepositoryGetRepositoryByPath(repoPath.c_str())); + BNRepository* repo = BNRepositoryGetRepositoryByPath(repoPath.c_str()); + if (!repo) + return nullptr; + return new Repository(repo); } Ref RepositoryManager::GetDefaultRepository() { - return new Repository(BNRepositoryManagerGetDefaultRepository()); + BNRepository* repo = BNRepositoryManagerGetDefaultRepository(); + if (!repo) + return nullptr; + return new Repository(repo); } -- cgit v1.3.1