Skip to content

Commit 69aeec9

Browse files
committed
udev: replace potential nullptrs by empty strings as we cannot construct std::string with a null const char*
fixes #154
1 parent 99ade0f commit 69aeec9

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • include/libremidi/backends/linux

include/libremidi/backends/linux/udev.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,25 @@ inline udev_soundcard_info get_udev_soundcard_info(const udev_helper& helper, in
165165
entry = udev.list_entry_get_next(entry))
166166
{
167167
auto path = udev.list_entry_get_name(entry);
168+
if (!path)
169+
continue;
170+
168171
auto dev = udev.device_new_from_syspath(helper.instance, path);
169-
auto usb_device = udev.device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device");
172+
if (!dev)
173+
continue;
174+
175+
const auto usb_device
176+
= udev.device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device");
177+
170178
port_information::port_type type = port_information::port_type::hardware;
171179
if (usb_device)
172180
type = (port_information::port_type)(type | port_information::port_type::usb);
173181
else
174182
type = (port_information::port_type)(type | port_information::port_type::pci);
175183

176184
auto id_path = udev.device_get_property_value(dev, "ID_PATH");
185+
if (!id_path)
186+
id_path = "";
177187

178188
auto ret = udev_soundcard_info{.container = id_path, .path = path, .type = type};
179189
udev.device_unref(dev);

0 commit comments

Comments
 (0)