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: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
20c4896b12
commit
52b5caa488
|
@ -1262,8 +1262,6 @@ static const IMFDXGIBufferVtbl dxgi_buffer_vtbl =
|
||||||
static HRESULT memory_buffer_init(struct buffer *buffer, DWORD max_length, DWORD alignment,
|
static HRESULT memory_buffer_init(struct buffer *buffer, DWORD max_length, DWORD alignment,
|
||||||
const IMFMediaBufferVtbl *vtbl)
|
const IMFMediaBufferVtbl *vtbl)
|
||||||
{
|
{
|
||||||
size_t size;
|
|
||||||
|
|
||||||
if (alignment < MF_16_BYTE_ALIGNMENT)
|
if (alignment < MF_16_BYTE_ALIGNMENT)
|
||||||
alignment = MF_16_BYTE_ALIGNMENT;
|
alignment = MF_16_BYTE_ALIGNMENT;
|
||||||
alignment++;
|
alignment++;
|
||||||
|
@ -1279,10 +1277,9 @@ static HRESULT memory_buffer_init(struct buffer *buffer, DWORD max_length, DWORD
|
||||||
alignment++;
|
alignment++;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = ALIGN_SIZE(max_length, alignment - 1);
|
if (!(buffer->data = _aligned_malloc(max_length, alignment)))
|
||||||
if (!(buffer->data = _aligned_malloc(size, alignment)))
|
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
memset(buffer->data, 0, size);
|
memset(buffer->data, 0, max_length);
|
||||||
|
|
||||||
buffer->IMFMediaBuffer_iface.lpVtbl = vtbl;
|
buffer->IMFMediaBuffer_iface.lpVtbl = vtbl;
|
||||||
buffer->refcount = 1;
|
buffer->refcount = 1;
|
||||||
|
|
Loading…
Reference in New Issue