From: Christian Heller Date: Sat, 31 Aug 2013 13:46:12 +0000 (+0200) Subject: Fixed bug that freed non-existing map objects, triggered segfaults. X-Git-Tag: tce~984 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/balance?a=commitdiff_plain;h=1872b8ed64328ebafec56b0888fa48f60fb4942b;p=plomrogue Fixed bug that freed non-existing map objects, triggered segfaults. --- diff --git a/src/map_objects.c b/src/map_objects.c index 28d9b14..d220556 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -308,10 +308,11 @@ extern void * build_map_objects(struct World * world, void * start, char def_id, extern void free_items(struct Item * item) { - if (0 != item->map_obj.next) + if (0 == item) { - free_items((struct Item *) item->map_obj.next); + return; } + free_items((struct Item *) item->map_obj.next); free(item); } @@ -319,10 +320,11 @@ extern void free_items(struct Item * item) extern void free_monsters(struct Monster * monster) { - if (0 != monster->map_obj.next) + if (0 == monster) { - free_monsters((struct Monster *) monster->map_obj.next); + return; } + free_monsters((struct Monster *) monster->map_obj.next); free(monster); }