tSanity check: don't call g_memmove with size=0, in case it does something dumb… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit cc1a291a6612b1827661efce49266aedff9fd15b | |
parent 042c82570e7df175a373eb93ada6b2c5b8737e5d | |
Author: Ben Webb <[email protected]> | |
Date: Thu, 25 Apr 2002 16:27:08 +0000 | |
Sanity check: don't call g_memmove with size=0, in case it does something dumb. | |
Diffstat: | |
M src/dopewars.c | 6 ++++-- | |
1 file changed, 4 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/src/dopewars.c b/src/dopewars.c | |
t@@ -1374,8 +1374,10 @@ void RemoveListEntry(DopeList *List, int Index) | |
if (!List || Index < 0 || Index >= List->Number) | |
return; | |
- g_memmove(&(List->Data[Index]), &(List->Data[Index + 1]), | |
- (List->Number - 1 - Index) * sizeof(DopeEntry)); | |
+ if (Index < List->Number - 1) { | |
+ g_memmove(&(List->Data[Index]), &(List->Data[Index + 1]), | |
+ (List->Number - 1 - Index) * sizeof(DopeEntry)); | |
+ } | |
List->Number--; | |
List->Data = (DopeEntry *)g_realloc(List->Data, List->Number * | |
sizeof(DopeEntry)); |