From 4bccc87f2bdae4e13e1870492e3f54a3e59aaccc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 Sep 2017 20:20:13 +0200 Subject: [PATCH] fix Invalid read (valgrind) in remove_skill --- clibs | 2 +- src/kernel/unit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clibs b/clibs index da2c0cc39..2a55c27fe 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit da2c0cc39b27c98ed8d31b0503426788fc236bd8 +Subproject commit 2a55c27fedec76845cf82c758b7b7c3fa649c286 diff --git a/src/kernel/unit.c b/src/kernel/unit.c index b2eeec055..47345c057 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1191,7 +1191,7 @@ void remove_skill(unit * u, skill_t sk) for (i = 0; i != u->skill_size; ++i) { sv = u->skills + i; if (sv->id == sk) { - memmove(sv, sv + 1, (u->skill_size - 1) * sizeof(skill)); + memmove(sv, sv + 1, (u->skill_size - i - 1) * sizeof(skill)); --u->skill_size; return; }