Skip to content

Commit

Permalink
WASAPI: Fix potentially uninitialized pointer warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrtk authored and kinetiknz committed Dec 9, 2020
1 parent 85f1cf4 commit 860bf2b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/cubeb_wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 860bf2b

Please sign in to comment.