Skip to content

Commit 860bf2b

Browse files
ggrtkkinetiknz
authored andcommitted
WASAPI: Fix potentially uninitialized pointer warning
1 parent 85f1cf4 commit 860bf2b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/cubeb_wasapi.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
21852185

21862186
void wasapi_find_matching_output_device(cubeb_stream * stm) {
21872187
HRESULT hr;
2188-
cubeb_device_info * input_device;
2188+
cubeb_device_info * input_device = nullptr;
21892189
cubeb_device_collection collection;
21902190

21912191
// 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) {
22202220

22212221
for (uint32_t i = 0; i < collection.count; i++) {
22222222
cubeb_device_info dev = collection.device[i];
2223-
if (dev.type == CUBEB_DEVICE_TYPE_OUTPUT &&
2224-
dev.group_id && !strcmp(dev.group_id, input_device->group_id) &&
2223+
if (dev.type == CUBEB_DEVICE_TYPE_OUTPUT && dev.group_id && input_device &&
2224+
!strcmp(dev.group_id, input_device->group_id) &&
22252225
dev.default_rate == input_device->default_rate) {
2226-
LOG("Found matching device for %s: %s", input_device->friendly_name, dev.friendly_name);
2227-
stm->output_device_id = utf8_to_wstr(reinterpret_cast<char const *>(dev.devid));
2226+
LOG("Found matching device for %s: %s", input_device->friendly_name,
2227+
dev.friendly_name);
2228+
stm->output_device_id =
2229+
utf8_to_wstr(reinterpret_cast<char const *>(dev.devid));
22282230
}
22292231
}
22302232

0 commit comments

Comments
 (0)