summaryrefslogtreecommitdiff
path: root/src/save.c
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2012-01-19 23:55:54 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-25 13:33:22 (GMT)
commitf0730818e4f8f0e2b96886cb340d5705f8d7dd92 (patch)
treebc3f532b9e8691ecb954cfbe253d89ccd6094fbe /src/save.c
parent4af8385a0ee0dcf8c29e322f994c66308da53c9c (diff)
downloadpowder-f0730818e4f8f0e2b96886cb340d5705f8d7dd92.zip
powder-f0730818e4f8f0e2b96886cb340d5705f8d7dd92.tar.gz
OPS thumbnail crash fix, and blank thumbnails for saves from a newer version
Diffstat (limited to 'src/save.c')
-rw-r--r--src/save.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/save.c b/src/save.c
index f0055d8..4cfca43 100644
--- a/src/save.c
+++ b/src/save.c
@@ -58,6 +58,7 @@ pixel *prerender_save_OPS(void *save, int size, int *width, int *height)
int inputDataLen = size, bsonDataLen = 0, partsDataLen, partsPosDataLen, wallDataLen;
int i, x, y, j;
int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
+ int bsonInitialised = 0;
pixel * vidBuf = NULL;
bson b;
bson_iterator iter;
@@ -121,6 +122,7 @@ pixel *prerender_save_OPS(void *save, int size, int *width, int *height)
}
bson_init_data(&b, bsonData);
+ bsonInitialised = 1;
bson_iterator_init(&iter, &b);
while(bson_iterator_next(&iter))
{
@@ -301,7 +303,9 @@ fail:
vidBuf = NULL;
}
fin:
- bson_destroy(&b);
+ //Don't call bson_destroy if bson_init wasn't called, or an uninitialised pointer (b.data) will be freed and the game will crash
+ if (bsonInitialised)
+ bson_destroy(&b);
return vidBuf;
}