summaryrefslogtreecommitdiff
path: root/board/esd
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2005-10-08 10:19:07 +0200
committerStefan Roese <sr@denx.de>2005-10-08 10:19:07 +0200
commitc29ab9d71d229ee94e8263845ea54222005e3880 (patch)
tree60bf999c52c3e7bce7320d4ac82a7a0d27c3096c /board/esd
parentbccae9039e59ac09a776429119389a6a4e679fd7 (diff)
downloadu-boot-imx-c29ab9d71d229ee94e8263845ea54222005e3880.zip
u-boot-imx-c29ab9d71d229ee94e8263845ea54222005e3880.tar.gz
u-boot-imx-c29ab9d71d229ee94e8263845ea54222005e3880.tar.bz2
Fix gzip bmp support (test if malloc fails, warning when truncated).
Increase CFG_VIDEO_LOGO_MAX_SIZE on HH405 board. Patch by Stefan Roese, 08 Oct 2005
Diffstat (limited to 'board/esd')
-rw-r--r--board/esd/common/lcd.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/board/esd/common/lcd.c b/board/esd/common/lcd.c
index 05c76ff..0edc083 100644
--- a/board/esd/common/lcd.c
+++ b/board/esd/common/lcd.c
@@ -81,7 +81,7 @@ void lcd_bmp(uchar *logo_bmp)
uchar *ptr;
ushort *ptr2;
ushort val;
- unsigned char *dst;
+ unsigned char *dst = NULL;
int x, y;
int width, height, bpp, colors, line_size;
int header_size;
@@ -89,7 +89,6 @@ void lcd_bmp(uchar *logo_bmp)
unsigned char r, g, b;
BITMAPINFOHEADER *bm_info;
ulong len;
- int do_free = 0;
/*
* Check for bmp mark 'BM'
@@ -99,12 +98,18 @@ void lcd_bmp(uchar *logo_bmp)
/*
* Decompress bmp image
*/
- len = CFG_LCD_LOGO_MAX_SIZE;
- dst = malloc(CFG_LCD_LOGO_MAX_SIZE);
- do_free = 1;
- if (gunzip(dst, CFG_LCD_LOGO_MAX_SIZE, (uchar *)logo_bmp, &len) != 0) {
+ len = CFG_VIDEO_LOGO_MAX_SIZE;
+ dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);
+ if (dst == NULL) {
+ printf("Error: malloc in gunzip failed!\n");
return;
}
+ if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)logo_bmp, &len) != 0) {
+ return;
+ }
+ if (len == CFG_VIDEO_LOGO_MAX_SIZE) {
+ printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n");
+ }
/*
* Check for bmp mark 'BM'
@@ -147,7 +152,9 @@ void lcd_bmp(uchar *logo_bmp)
break;
default:
printf("LCD: Unknown bpp (%d) im image!\n", bpp);
- free(dst);
+ if ((dst != NULL) && (dst != (uchar *)logo_bmp)) {
+ free(dst);
+ }
return;
}
printf(" (%d*%d, %dbpp)\n", width, height, bpp);
@@ -205,7 +212,7 @@ void lcd_bmp(uchar *logo_bmp)
}
}
- if (do_free) {
+ if ((dst != NULL) && (dst != (uchar *)logo_bmp)) {
free(dst);
}
}