In rte_realloc, if the old element has pad and need to allocate a new
memory, the padding size was not deducted, so more data was copied to
new data area.
Fixes:
af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
void *new_ptr = rte_malloc_socket(NULL, size, align, socket);
if (new_ptr == NULL)
return NULL;
- const unsigned old_size = elem->size - MALLOC_ELEM_OVERHEAD;
+ /* elem: |pad|data_elem|data|trailer| */
+ const size_t old_size = elem->size - elem->pad - MALLOC_ELEM_OVERHEAD;
rte_memcpy(new_ptr, ptr, old_size < size ? old_size : size);
rte_free(ptr);