From f3fa455732a670f45d225a02519fb4b09beacadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20LE=20STUM?= <sebastien.le-stum@savoirfairelinux.com> Date: Wed, 30 Sep 2020 15:34:46 -0400 Subject: [PATCH] plugin: prevent potential nullptr dereference Remove potential NULL pointer dereference in the case of plugin pointer being NULL. Change-Id: Iaf7fd6c4d0c44983723827dbba89f18136c8954a --- src/plugin/pluginmanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugin/pluginmanager.cpp b/src/plugin/pluginmanager.cpp index 7a0848823e..4d423358d6 100644 --- a/src/plugin/pluginmanager.cpp +++ b/src/plugin/pluginmanager.cpp @@ -184,15 +184,15 @@ PluginManager::registerPlugin(std::unique_ptr<Plugin>& plugin) */ pluginPtr->api_.manageComponent = [](const JAMI_PluginAPI* api, const char* name, void* data) { auto plugin = static_cast<DLPlugin*>(api->context); + if (!plugin) { + JAMI_ERR() << "createComponent called with null context"; + return -1; + } auto manager = reinterpret_cast<PluginManager*>(plugin->apiContext_); if (!manager) { JAMI_ERR() << "createComponent called with null plugin API"; return -1; - } else if (!plugin) { - JAMI_ERR() << "createComponent called with null context"; - return -1; } - return manager->manageComponent(plugin, name, data); }; -- GitLab