fix Invalid read (valgrind) in remove_skill

This commit is contained in:
Enno Rehling 2017-09-18 20:20:13 +02:00
parent 832ba5f948
commit 4bccc87f2b
2 changed files with 2 additions and 2 deletions

2
clibs

@ -1 +1 @@
Subproject commit da2c0cc39b27c98ed8d31b0503426788fc236bd8 Subproject commit 2a55c27fedec76845cf82c758b7b7c3fa649c286

View File

@ -1191,7 +1191,7 @@ void remove_skill(unit * u, skill_t sk)
for (i = 0; i != u->skill_size; ++i) { for (i = 0; i != u->skill_size; ++i) {
sv = u->skills + i; sv = u->skills + i;
if (sv->id == sk) { 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; --u->skill_size;
return; return;
} }