From dca3b154ef5cff40611d11723848c6f5c51e6b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 6 May 2026 15:00:52 +0800 Subject: [PATCH] Global (Windows): fixes possible use-before-init errors --- src/detection/camera/camera_windows.cpp | 4 ++-- src/detection/sound/sound_windows.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/detection/camera/camera_windows.cpp b/src/detection/camera/camera_windows.cpp index fb7a653ea..48ee9dc45 100644 --- a/src/detection/camera/camera_windows.cpp +++ b/src/detection/camera/camera_windows.cpp @@ -72,13 +72,13 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { continue; } - IMFStreamDescriptor* FF_AUTO_RELEASE_COM_OBJECT sd = NULL; + IMFStreamDescriptor* FF_AUTO_RELEASE_COM_OBJECT sd = nullptr; BOOL selected; if (FAILED(pd->GetStreamDescriptorByIndex(0, &selected, &sd))) { continue; } - IMFMediaTypeHandler* FF_AUTO_RELEASE_COM_OBJECT handler = NULL; + IMFMediaTypeHandler* FF_AUTO_RELEASE_COM_OBJECT handler = nullptr; if (FAILED(sd->GetMediaTypeHandler(&handler))) { continue; } diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index c770f5c97..835eb63a2 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -25,7 +25,7 @@ static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */ return "immDevice->GetId() failed"; } - IPropertyStore* FF_AUTO_RELEASE_COM_OBJECT immPropStore; + IPropertyStore* FF_AUTO_RELEASE_COM_OBJECT immPropStore = NULL; if (FAILED(immDevice->OpenPropertyStore(STGM_READ, &immPropStore))) { return "immDevice->OpenPropertyStore() failed"; } @@ -54,7 +54,7 @@ static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */ } } - IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume; + IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume = NULL; if (SUCCEEDED(immDevice->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**) &immEndpointVolume))) { BOOL muted; if (FAILED(immEndpointVolume->GetMute(&muted)) || !muted) {