From 293f7c7d3dc82ff4ea841189bbfadccf405b8f7b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 3 Oct 2023 20:06:29 +0300 Subject: [PATCH 56/56] Create moving animation virtual unit What's supposed to be virtual unit was actually direct pointer to the real unit. Among other problems that meant that after the real unit gets wiped (dies, moves out of sight), animations were doing illegal memory accesses. This resulted also in double frees as we freed what was supposed to be the virtual unit. Reported by mortmann See osdn #48797 Signed-off-by: Marko Lindqvist --- client/mapview_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/mapview_common.c b/client/mapview_common.c index 029dd5a38f..2c8ac04edc 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -2751,7 +2751,11 @@ void move_unit_map_canvas(struct unit *punit, anim->type = ANIM_MOVEMENT; anim->id = punit->id; punit->refcount++; - anim->movement.mover = punit; + anim->movement.mover = unit_virtual_create(unit_owner(punit), + NULL, unit_type_get(punit), + punit->veteran); + anim->movement.mover->hp = punit->hp; + anim->movement.mover->facing = punit->facing; anim->movement.src = src_tile; anim->movement.dest = dest_tile; anim->movement.canvas_dx = canvas_dx; -- 2.40.1