Skip to content
Snippets Groups Projects
Commit 423c3340 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

device monitor: avoid potential null pointer dereference

Change-Id: Ic1cdeacaa73e496c0c1483fdaf2db1e95474e5d3
parent a9b7ade5
No related branches found
No related tags found
No related merge requests found
...@@ -683,7 +683,7 @@ setEncodingAccelerated(bool state) ...@@ -683,7 +683,7 @@ setEncodingAccelerated(bool state)
#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) #if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
void void
addVideoDevice(const std::string& node, addVideoDevice(const std::string& node,
std::vector<std::map<std::string, std::string>> const* devInfo) const std::vector<std::map<std::string, std::string>>& devInfo)
{ {
jami::Manager::instance().getVideoManager().videoDeviceMonitor.addDevice(node, devInfo); jami::Manager::instance().getVideoManager().videoDeviceMonitor.addDevice(node, devInfo);
} }
......
...@@ -213,7 +213,7 @@ DRING_PUBLIC void stopLocalRecorder(const std::string& filepath); ...@@ -213,7 +213,7 @@ DRING_PUBLIC void stopLocalRecorder(const std::string& filepath);
#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) #if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
DRING_PUBLIC void addVideoDevice( DRING_PUBLIC void addVideoDevice(
const std::string& node, const std::string& node,
const std::vector<std::map<std::string, std::string>>* devInfo = nullptr); const std::vector<std::map<std::string, std::string>>& devInfo = {});
DRING_PUBLIC void removeVideoDevice(const std::string& node); DRING_PUBLIC void removeVideoDevice(const std::string& node);
DRING_PUBLIC VideoFrame* getNewFrame(); DRING_PUBLIC VideoFrame* getNewFrame();
DRING_PUBLIC void publishFrame(); DRING_PUBLIC void publishFrame();
......
...@@ -148,9 +148,7 @@ VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor) ...@@ -148,9 +148,7 @@ VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor)
try { try {
auto unique_name = getDeviceString(dev); auto unique_name = getDeviceString(dev);
JAMI_DBG("udev: adding device with id %s", unique_name.c_str()); JAMI_DBG("udev: adding device with id %s", unique_name.c_str());
std::map<std::string, std::string> info = {{"devPath", path}}; monitor_->addDevice(unique_name, {{{"devPath", path}}});
std::vector<std::map<std::string, std::string>> devInfo = {info};
monitor_->addDevice(unique_name, &devInfo);
currentPathToId_.emplace(path, unique_name); currentPathToId_.emplace(path, unique_name);
} catch (const std::exception& e) { } catch (const std::exception& e) {
JAMI_ERR("%s", e.what()); JAMI_ERR("%s", e.what());
...@@ -237,9 +235,7 @@ VideoDeviceMonitorImpl::run() ...@@ -237,9 +235,7 @@ VideoDeviceMonitorImpl::run()
const char* action = udev_device_get_action(dev); const char* action = udev_device_get_action(dev);
if (!strcmp(action, "add")) { if (!strcmp(action, "add")) {
JAMI_DBG("udev: adding device with id %s", unique_name.c_str()); JAMI_DBG("udev: adding device with id %s", unique_name.c_str());
std::map<std::string, std::string> info = {{"devPath", path}}; monitor_->addDevice(unique_name, {{{"devPath", path}}});
std::vector<std::map<std::string, std::string>> devInfo = {info};
monitor_->addDevice(unique_name, &devInfo);
currentPathToId_.emplace(path, unique_name); currentPathToId_.emplace(path, unique_name);
} else if (!strcmp(action, "remove")) { } else if (!strcmp(action, "remove")) {
auto it = currentPathToId_.find(path); auto it = currentPathToId_.find(path);
......
...@@ -185,7 +185,7 @@ notify() ...@@ -185,7 +185,7 @@ notify()
void void
VideoDeviceMonitor::addDevice(const string& id, VideoDeviceMonitor::addDevice(const string& id,
const std::vector<std::map<std::string, std::string>>* devInfo) const std::vector<std::map<std::string, std::string>>& devInfo)
{ {
try { try {
std::lock_guard<std::mutex> l(lock_); std::lock_guard<std::mutex> l(lock_);
...@@ -193,7 +193,7 @@ VideoDeviceMonitor::addDevice(const string& id, ...@@ -193,7 +193,7 @@ VideoDeviceMonitor::addDevice(const string& id,
return; return;
// instantiate a new unique device // instantiate a new unique device
VideoDevice dev {id, *devInfo}; VideoDevice dev {id, devInfo};
if (dev.getChannelList().empty()) if (dev.getChannelList().empty())
return; return;
......
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
void setDeviceOrientation(const std::string& id, int angle); void setDeviceOrientation(const std::string& id, int angle);
void addDevice(const std::string& node, void addDevice(const std::string& node,
const std::vector<std::map<std::string, std::string>>* devInfo = nullptr); const std::vector<std::map<std::string, std::string>>& devInfo = {});
void removeDevice(const std::string& node); void removeDevice(const std::string& node);
void removeDeviceViaInput(const std::string& path); void removeDeviceViaInput(const std::string& path);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment