1
0
Fork 0

lcd: avoid possible NULL dereference

Do not dereference bmp before the check if it is NULL.

The problem was indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
zero-sugar
xypron.glpk@gmx.de 2017-07-30 21:59:23 +02:00 committed by Anatolij Gustschin
parent 5619295995
commit 021414a332
1 changed files with 2 additions and 1 deletions

View File

@ -578,7 +578,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
unsigned long pwidth = panel_info.vl_col;
unsigned colors, bpix, bmp_bpix;
int hdr_size;
struct bmp_color_table_entry *palette = bmp->color_table;
struct bmp_color_table_entry *palette;
if (!bmp || !(bmp->header.signature[0] == 'B' &&
bmp->header.signature[1] == 'M')) {
@ -587,6 +587,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
return 1;
}
palette = bmp->color_table;
width = get_unaligned_le32(&bmp->header.width);
height = get_unaligned_le32(&bmp->header.height);
bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);