aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/font.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/graphics/font.cpp b/graphics/font.cpp
index 1c958f3c3c..e0c9fdecf4 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -572,8 +572,10 @@ bitmap_t bdf_hexval(unsigned char *buf) {
NewFont *NewFont::loadFont(Common::SeekableReadStream &stream) {
NewFontData *data = bdf_read_font(stream);
- if (!data)
+ if (!data || stream.err()) {
+ free_font(data);
return 0;
+ }
FontDesc desc;
desc.name = data->name;
@@ -673,7 +675,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
data->defaultchar = stream.readUint16BE();
data->bits_size = stream.readUint32BE();
- data->bits = (bitmap_t*)malloc(sizeof(bitmap_t)*data->bits_size);
+ data->bits = (bitmap_t *)malloc(sizeof(bitmap_t) * data->bits_size);
if (!data->bits) {
free(data);
return 0;
@@ -685,7 +687,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
bool hasOffsetTable = (stream.readByte() != 0);
if (hasOffsetTable) {
- data->offset = (unsigned long*)malloc(sizeof(unsigned long)*data->size);
+ data->offset = (unsigned long *)malloc(sizeof(unsigned long) * data->size);
if (!data->offset) {
free(data->bits);
free(data);
@@ -699,7 +701,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
bool hasWidthTable = (stream.readByte() != 0);
if (hasWidthTable) {
- data->width = (unsigned char*)malloc(sizeof(unsigned char)*data->size);
+ data->width = (unsigned char *)malloc(sizeof(unsigned char) * data->size);
if (!data->width) {
free(data->bits);
free(data->offset);
@@ -714,7 +716,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
bool hasBBXTable = (stream.readByte() != 0);
if (hasBBXTable) {
- data->bbx = (BBX *)malloc(sizeof(BBX)*data->size);
+ data->bbx = (BBX *)malloc(sizeof(BBX) * data->size);
if (!data->bbx) {
free(data->bits);
free(data->offset);
@@ -750,7 +752,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
desc.bits_size = data->bits_size;
font = new NewFont(desc, data);
- if (!font || stream.ioFailed()) {
+ if (!font || stream.err()) {
free(data->bits);
free(data->offset);
free(data->width);