summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-03 00:05:51 +0000
committersmatz <smatz@openttd.org>2009-06-03 00:05:51 +0000
commitd1a50f525835f7c9f40a80c60e58e535e6ad5f32 (patch)
tree7dea2acfc0ffc0af550a5877c5d85b80a9b1b51d
parent2b4d37de3dfc1500288190d360fd64a5ca9b7f6e (diff)
downloadopenttd-d1a50f525835f7c9f40a80c60e58e535e6ad5f32.tar.xz
(svn r16507) -Fix (r16503): segfault when deleting non-last graphics set
-rw-r--r--src/gfxinit.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 9ef205895..73f2dd3d3 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -459,8 +459,8 @@ bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length)
}
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 @@ bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length)
*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;