commit 2fb440b183ccd78f46e865faca1504d45d6d09d0
parent 2e9921f9bc54ac2034521aa2758555dfd621c6c7
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Mon, 23 Oct 2023 08:44:30 +0800
windows: declare all types at top of function
This fixes segfault condition on error. If we goto the done label before
these types are declared and initialized, we get a segfault.
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Diffstat:
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/audio_windows.c b/audio_windows.c
@@ -693,6 +693,11 @@ Decode(BYTE* compressed, UINT size)
// buffer.
IStream * mem_stream = SHCreateMemStream(compressed, size);
+ IMFMediaType * m_type = NULL;
+ IMFMediaType * pUncompressedAudioType = NULL;
+ IMFMediaType * pPartialType = NULL;
+ Buffer * buffer = BufferNew();
+
hr = MFCreateMFByteStreamOnStream(mem_stream, &stream);
if (FAILED(hr))
@@ -711,10 +716,6 @@ Decode(BYTE* compressed, UINT size)
goto done;
}
- IMFMediaType * m_type = NULL;
-
- IMFMediaType * pUncompressedAudioType = NULL;
- IMFMediaType * pPartialType = NULL;
hr = ConfigureAudioStream(reader, &pUncompressedAudioType, &pPartialType, &m_type);
@@ -732,8 +733,6 @@ Decode(BYTE* compressed, UINT size)
goto done;
}
- Buffer * buffer = BufferNew();
-
r.Err = decode(reader, buffer);
if (r.Err != NULL)
@@ -807,6 +806,10 @@ Load(char* path)
.Channels = 0,
}
};
+
+ IMFMediaType * m_type = NULL;
+ IMFMediaType * pUncompressedAudioType = NULL;
+ IMFMediaType * pPartialType = NULL;
Result r = NewSourceReaderForFile(path);
@@ -818,10 +821,6 @@ Load(char* path)
reader = (IMFSourceReader*)(r.Value);
- IMFMediaType * m_type = NULL;
-
- IMFMediaType * pUncompressedAudioType = NULL;
- IMFMediaType * pPartialType = NULL;
hr = ConfigureAudioStream(reader, &pUncompressedAudioType, &pPartialType, &m_type);