Commit 423c3340 authored by Adrien Béraud's avatar Adrien Béraud

device monitor: avoid potential null pointer dereference

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