aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/pipewire.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-02-11 20:03:59 -0800
committerChris Robinson <[email protected]>2023-02-11 20:03:59 -0800
commit2001d93b03dd2af62e341b91ab2bee9b92da03bc (patch)
tree10268ae8df33330ec11ef484718cc3585dd5f82d /alc/backends/pipewire.cpp
parent44b6ac7db0c639a55441076042475cfae5a76d05 (diff)
Check a string for NULL before calling strtoull
Diffstat (limited to 'alc/backends/pipewire.cpp')
-rw-r--r--alc/backends/pipewire.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 04cc38c7..7bde4b78 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -884,17 +884,18 @@ void NodeProxy::infoCallback(const pw_node_info *info)
if(!nodeName || !*nodeName) nodeName = spa_dict_lookup(info->props, PW_KEY_NODE_NICK);
if(!nodeName || !*nodeName) nodeName = devName;
+ uint64_t serial_id{info->id};
#ifdef PW_KEY_OBJECT_SERIAL
- char *serial_end{};
- const char *serial_str{spa_dict_lookup(info->props, PW_KEY_OBJECT_SERIAL)};
- uint64_t serial_id{std::strtoull(serial_str, &serial_end, 0)};
- if(*serial_end != '\0' || errno == ERANGE)
+ if(const char *serial_str{spa_dict_lookup(info->props, PW_KEY_OBJECT_SERIAL)})
{
- ERR("Unexpected object serial: %s\n", serial_str);
- serial_id = info->id;
+ char *serial_end{};
+ serial_id = std::strtoull(serial_str, &serial_end, 0);
+ if(*serial_end != '\0' || errno == ERANGE)
+ {
+ ERR("Unexpected object serial: %s\n", serial_str);
+ serial_id = info->id;
+ }
}
-#else
- uint64_t serial_id{info->id};
#endif
const char *form_factor{spa_dict_lookup(info->props, PW_KEY_DEVICE_FORM_FACTOR)};