diff --git a/server/object.c b/server/object.c index 77dec733a54..729114ff9c3 100644 --- a/server/object.c +++ b/server/object.c @@ -67,11 +67,21 @@ void dump_objects(void) void close_objects(void) { - struct object *obj, *obj2; - /* release the permanent objects */ - LIST_FOR_EACH_ENTRY_SAFE( obj, obj2, &object_list, struct object, obj_list ) - if (obj->is_permanent) release_object( obj ); + for (;;) + { + struct object *obj; + int found = 0; + + LIST_FOR_EACH_ENTRY( obj, &object_list, struct object, obj_list ) + { + if (!(found = obj->is_permanent)) continue; + obj->is_permanent = 0; + release_object( obj ); + break; + } + if (!found) break; + } dump_objects(); /* dump any remaining objects */ }