changeset 12097:6df400d87245 draft

(svn r16507) -Fix (r16503): segfault when deleting non-last graphics set
author smatz <smatz@openttd.org>
date Wed, 03 Jun 2009 00:05:51 +0000
parents f8d1c7749ab0
children cd5dd7b1dbc5
files src/gfxinit.cpp
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -459,8 +459,8 @@
 	}
 
 	if (FillGraphicsSetDetails(graphics, ini, path)) {
-		const GraphicsSet *duplicate = NULL;
-		for (const GraphicsSet *c = _available_graphics_sets; c != NULL; c = c->next) {
+		GraphicsSet *duplicate = NULL;
+		for (GraphicsSet *c = _available_graphics_sets; c != NULL; c = c->next) {
 			if (strcmp(c->name, graphics->name) == 0 || c->shortname == graphics->shortname) {
 				duplicate = c;
 				break;
@@ -476,6 +476,8 @@
 
 				*prev = graphics;
 				graphics->next = duplicate->next;
+				/* don't allow recursive delete of all remaining items */
+				duplicate->next = NULL;
 
 				DEBUG(grf, 1, "Removing %s (%i) as base graphics set (duplicate)", duplicate->name, duplicate->version);
 				delete duplicate;