OPS thumbnail crash fix, and blank thumbnails for saves from a newer version

This commit is contained in:
jacksonmj 2012-01-20 07:55:54 +08:00 committed by Simon Robertshaw
parent 4af8385a0e
commit f0730818e4
2 changed files with 9 additions and 5 deletions

View File

@ -6276,13 +6276,13 @@ void catalogue_ui(pixel * vid_buf)
csave->image = resample_img(tmpimage, imgwidth, imgheight, XRES/CATALOGUE_S, YRES/CATALOGUE_S);
free(tmpimage);
} else {
//Blank image, this should default to something else
csave->image = malloc((XRES/CATALOGUE_S)*(YRES/CATALOGUE_S)*PIXELSIZE);
//Blank image, TODO: this should default to something else
csave->image = calloc((XRES/CATALOGUE_S)*(YRES/CATALOGUE_S), PIXELSIZE);
}
free(data);
} else {
//Blank image, this should default to something else
csave->image = malloc((XRES/CATALOGUE_S)*(YRES/CATALOGUE_S)*PIXELSIZE);
//Blank image, TODO: this should default to something else
csave->image = calloc((XRES/CATALOGUE_S)*(YRES/CATALOGUE_S), PIXELSIZE);
}
imageoncycle = 1;
}

View File

@ -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;
}