avutil/buffer: support memory poisoning
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@ -71,6 +71,9 @@ AVBufferRef *av_buffer_alloc(int size)
|
|||||||
if (!data)
|
if (!data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if(CONFIG_MEMORY_POISONING)
|
||||||
|
memset(data, 0x2a, size);
|
||||||
|
|
||||||
ret = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
|
ret = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
av_freep(&data);
|
av_freep(&data);
|
||||||
@ -276,6 +279,10 @@ static void pool_release_buffer(void *opaque, uint8_t *data)
|
|||||||
{
|
{
|
||||||
BufferPoolEntry *buf = opaque;
|
BufferPoolEntry *buf = opaque;
|
||||||
AVBufferPool *pool = buf->pool;
|
AVBufferPool *pool = buf->pool;
|
||||||
|
|
||||||
|
if(CONFIG_MEMORY_POISONING)
|
||||||
|
memset(buf->data, 0x2a, pool->size);
|
||||||
|
|
||||||
add_to_pool(buf);
|
add_to_pool(buf);
|
||||||
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
|
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
|
||||||
buffer_pool_free(pool);
|
buffer_pool_free(pool);
|
||||||
|
Reference in New Issue
Block a user