aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlbert Liu <[email protected]>2020-12-08 16:53:26 -0800
committerMatthew Gregan <[email protected]>2020-12-09 14:35:48 +1300
commit860bf2b31531e4ef49478a433ff22ffb4303b805 (patch)
tree169be97354cc532b885e087bb096d0f4a411c536
parent85f1cf48dffd749dd32798681955155e1a1a6ff5 (diff)
downloadcubeb-860bf2b31531e4ef49478a433ff22ffb4303b805.tar.gz
cubeb-860bf2b31531e4ef49478a433ff22ffb4303b805.zip
WASAPI: Fix potentially uninitialized pointer warning
-rw-r--r--src/cubeb_wasapi.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index 30a6d06..d7c9eae 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -2185,7 +2185,7 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
void wasapi_find_matching_output_device(cubeb_stream * stm) {
HRESULT hr;
- cubeb_device_info * input_device;
+ cubeb_device_info * input_device = nullptr;
cubeb_device_collection collection;
// Only try to match to an output device if the input device is a bluetooth
@@ -2220,11 +2220,13 @@ void wasapi_find_matching_output_device(cubeb_stream * stm) {
for (uint32_t i = 0; i < collection.count; i++) {
cubeb_device_info dev = collection.device[i];
- if (dev.type == CUBEB_DEVICE_TYPE_OUTPUT &&
- dev.group_id && !strcmp(dev.group_id, input_device->group_id) &&
+ if (dev.type == CUBEB_DEVICE_TYPE_OUTPUT && dev.group_id && input_device &&
+ !strcmp(dev.group_id, input_device->group_id) &&
dev.default_rate == input_device->default_rate) {
- LOG("Found matching device for %s: %s", input_device->friendly_name, dev.friendly_name);
- stm->output_device_id = utf8_to_wstr(reinterpret_cast<char const *>(dev.devid));
+ LOG("Found matching device for %s: %s", input_device->friendly_name,
+ dev.friendly_name);
+ stm->output_device_id =
+ utf8_to_wstr(reinterpret_cast<char const *>(dev.devid));
}
}