Commit 52b5caa4 authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

mfplat: Do not allocate more memory than requested.

It is totally fine (though maybe a little strange) to allocate 10 bytes requesting an alignment to a megabyte boundary or more, and this shouldn't result in wasting an (nearly) entire megabyte of memory. Signed-off-by: 's avatarGiovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: 's avatarNikolay Sivov <nsivov@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 20c4896b
......@@ -1262,8 +1262,6 @@ static const IMFDXGIBufferVtbl dxgi_buffer_vtbl =
static HRESULT memory_buffer_init(struct buffer *buffer, DWORD max_length, DWORD alignment,
const IMFMediaBufferVtbl *vtbl)
{
size_t size;
if (alignment < MF_16_BYTE_ALIGNMENT)
alignment = MF_16_BYTE_ALIGNMENT;
alignment++;
......@@ -1279,10 +1277,9 @@ static HRESULT memory_buffer_init(struct buffer *buffer, DWORD max_length, DWORD
alignment++;
}
size = ALIGN_SIZE(max_length, alignment - 1);
if (!(buffer->data = _aligned_malloc(size, alignment)))
if (!(buffer->data = _aligned_malloc(max_length, alignment)))
return E_OUTOFMEMORY;
memset(buffer->data, 0, size);
memset(buffer->data, 0, max_length);
buffer->IMFMediaBuffer_iface.lpVtbl = vtbl;
buffer->refcount = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment