diff options
| author | 0cyn <kat@vector35.com> | 2026-04-15 12:40:35 -0400 |
|---|---|---|
| committer | 0cyn <kat@vector35.com> | 2026-04-15 12:40:35 -0400 |
| commit | 15996cf9058ffd0b4d05ef56204b21e903bdd523 (patch) | |
| tree | 195ebfd3bc833c487f35e5d387cf9b57411ef623 /pluginmanager.cpp | |
| parent | 65582278e36dd9905c22a47620c70cf39d8fde63 (diff) | |
Improve nullptr checks across Extensions API
Diffstat (limited to 'pluginmanager.cpp')
| -rw-r--r-- | pluginmanager.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
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<Repository> 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<Repository> RepositoryManager::GetDefaultRepository() { - return new Repository(BNRepositoryManagerGetDefaultRepository()); + BNRepository* repo = BNRepositoryManagerGetDefaultRepository(); + if (!repo) + return nullptr; + return new Repository(repo); } |
