summaryrefslogtreecommitdiff
path: root/image/bmpread.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2008-06-01 00:15:53 +0000
committerJames Bursa <james@netsurf-browser.org>2008-06-01 00:15:53 +0000
commit70c7b81c2fd459c87697216b69c2bd17e5d3086c (patch)
treec01c67c82c9a80e9f0ac2cf3697ea25257da98cf /image/bmpread.c
parent21a3c99d3dcf20e13cdcf16fda6f01f6e6a3a1b3 (diff)
downloadnetsurf-70c7b81c2fd459c87697216b69c2bd17e5d3086c.tar.gz
netsurf-70c7b81c2fd459c87697216b69c2bd17e5d3086c.tar.bz2
Improve MNG error handling to show error code. Fix code not expecting bitmap_get_buffer() to return 0.
svn path=/trunk/netsurf/; revision=4237
Diffstat (limited to 'image/bmpread.c')
-rw-r--r--image/bmpread.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/image/bmpread.c b/image/bmpread.c
index 7e6a9fefa..cf11ab807 100644
--- a/image/bmpread.c
+++ b/image/bmpread.c
@@ -127,7 +127,7 @@ bmp_result ico_analyse(struct ico_collection *ico) {
image->bmp.bmp_data = ico->ico_data + READ_INT(data, 12);
image->bmp.ico = true;
data += 16;
- result = bmp_analyse_header(&image->bmp,
+ result = bmp_analyse_header(&image->bmp,
(char *) image->bmp.bmp_data);
if (result != BMP_OK)
return result;
@@ -425,6 +425,8 @@ bmp_result bmp_decode_rgb24(struct bmp_image *bmp, char **start, int bytes) {
data = *start;
swidth = bitmap_get_rowstride(bmp->bitmap);
top = bitmap_get_buffer(bmp->bitmap);
+ if (!top)
+ return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
end = data + bytes;
addr = ((intptr_t)data) & 3;
@@ -485,6 +487,8 @@ bmp_result bmp_decode_rgb16(struct bmp_image *bmp, char **start, int bytes) {
data = *start;
swidth = bitmap_get_rowstride(bmp->bitmap);
top = bitmap_get_buffer(bmp->bitmap);
+ if (!top)
+ return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
end = data + bytes;
addr = ((intptr_t)data) & 3;
@@ -552,6 +556,8 @@ bmp_result bmp_decode_rgb(struct bmp_image *bmp, char **start, int bytes) {
data = *start;
swidth = bitmap_get_rowstride(bmp->bitmap);
top = bitmap_get_buffer(bmp->bitmap);
+ if (!top)
+ return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
end = data + bytes;
addr = ((intptr_t)data) & 3;
@@ -598,6 +604,8 @@ bmp_result bmp_decode_mask(struct bmp_image *bmp, char *data, int bytes) {
swidth = bitmap_get_rowstride(bmp->bitmap);
top = bitmap_get_buffer(bmp->bitmap);
+ if (!top)
+ return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
end = data + bytes;
addr = ((intptr_t)data) & 3;
@@ -642,6 +650,8 @@ bmp_result bmp_decode_rle(struct bmp_image *bmp, char *data, int bytes, int size
swidth = bitmap_get_rowstride(bmp->bitmap);
top = bitmap_get_buffer(bmp->bitmap);
+ if (!top)
+ return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
end = data + bytes;
bmp->decoded = true;