--- a/lib/stackdepot.c~lib-stackdepotc-use-flex_array_size-helper-in-memcpy +++ a/lib/stackdepot.c @@ -135,7 +135,7 @@ static struct stack_record *depot_alloc_ stack->handle.slabindex = depot_index; stack->handle.offset = depot_offset >> STACK_ALLOC_ALIGN; stack->handle.valid = 1; - memcpy(stack->entries, entries, size * sizeof(unsigned long)); + memcpy(stack->entries, entries, flex_array_size(stack, entries, size)); depot_offset += required_size; return stack;