wasapi: Fix alloc/free function mismatch

... and fix leak in wasapi device provider

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3326
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6169>
This commit is contained in:
Seungha Yang 2024-02-21 21:50:20 +09:00 committed by GStreamer Marge Bot
parent 06b9864dae
commit 911d840288

View file

@ -407,6 +407,7 @@ gst_wasapi_util_get_devices (GstMMDeviceEnumerator * self,
GstDevice *device;
GstStructure *props;
GstCaps *caps;
gboolean parse_ret;
hr = IMMDeviceCollection_Item (device_collection, ii, &item);
if (hr != S_OK)
@ -469,8 +470,12 @@ gst_wasapi_util_get_devices (GstMMDeviceEnumerator * self,
goto next;
}
if (!gst_wasapi_util_parse_waveformatex ((WAVEFORMATEXTENSIBLE *) format,
gst_static_caps_get (&scaps), &caps, NULL))
parse_ret =
gst_wasapi_util_parse_waveformatex ((WAVEFORMATEXTENSIBLE *) format,
gst_static_caps_get (&scaps), &caps, NULL);
CoTaskMemFree (format);
if (!parse_ret)
goto next;
/* Set some useful properties */
@ -556,7 +561,7 @@ gst_wasapi_util_get_device_format (GstElement * self,
return FALSE;
}
format = malloc (var.blob.cbSize);
format = CoTaskMemAlloc (var.blob.cbSize);
memcpy (format, var.blob.pBlobData, var.blob.cbSize);
PropVariantClear (&var);
@ -570,7 +575,7 @@ gst_wasapi_util_get_device_format (GstElement * self,
goto out;
GST_ERROR_OBJECT (self, "AudioEngine DeviceFormat not supported");
free (format);
CoTaskMemFree (format);
return FALSE;
out: