Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/buffer.c | 2 +- dlls/mfplat/tests/mfplat.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 1727ff1e90..7c123e3e65 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -1235,7 +1235,7 @@ static HRESULT WINAPI sample_ConvertToContiguousBuffer(IMFSample *iface, IMFMedi } }
- if (SUCCEEDED(hr)) + if (SUCCEEDED(hr) && buffer) { *buffer = sample->buffers[0]; IMFMediaBuffer_AddRef(*buffer); diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index a2bc7115a5..8f0abb8ec7 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -1993,6 +1993,9 @@ static void test_sample(void) ok(buffer2 == buffer, "Unexpected buffer instance.\n"); IMFMediaBuffer_Release(buffer2);
+ hr = IMFSample_ConvertToContiguousBuffer(sample, NULL); + ok(hr == S_OK, "Failed to convert, hr %#x.\n", hr); + hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer2); ok(hr == S_OK, "Failed to convert, hr %#x.\n", hr); ok(buffer2 == buffer, "Unexpected buffer instance.\n"); @@ -2026,8 +2029,21 @@ static void test_sample(void) ok(hr == S_OK, "Failed to get maximum length, hr %#x.\n", hr); ok(length == 7, "Unexpected length %u.\n", length);
- if (SUCCEEDED(hr)) - IMFMediaBuffer_Release(buffer3); + IMFMediaBuffer_Release(buffer3); + + hr = IMFSample_GetBufferCount(sample, &count); + ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr); + ok(count == 1, "Unexpected buffer count %u.\n", count); + + hr = IMFSample_AddBuffer(sample, buffer); + ok(hr == S_OK, "Failed to add buffer, hr %#x.\n", hr); + + hr = IMFSample_GetBufferCount(sample, &count); + ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr); + ok(count == 2, "Unexpected buffer count %u.\n", count); + + hr = IMFSample_ConvertToContiguousBuffer(sample, NULL); + ok(hr == S_OK, "Failed to convert, hr %#x.\n", hr);
hr = IMFSample_GetBufferCount(sample, &count); ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr);