On Wed, 2020-08-12 at 16:29 +0800, Zhiqiang Liu wrote: > In vector_alloc_slot func, if REALLOC fails, it means new slot > allocation fails. However, it just update v->allocated and then > return the old v->slot without new slot. So, the caller will take > the last old slot as the new allocated slot, and use it by calling > vector_set_slot func. Finally, the data of last slot is lost. > > Here, we rewrite vector_alloc_slot as suggested by Martin Wilck: > - increment v->allocated only after successful allocation, > - avoid the "if (v->slot)" conditional by just calling realloc(), > - make sure all newly allocated vector elements are set to NULL, > - change return value to bool. > > Signed-off-by: Zhiqiang Liu <liuzhiqiang26@xxxxxxxxxx> > Signed-off-by: lixiaokeng <lixiaokeng@xxxxxxxxxx> > Reviewed-by: Martin Wilck <mwilck@xxxxxxxx> -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel