mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-02 01:18:04 +08:00
fix(png) check png magic number to be sure it's a png image
This commit is contained in:
@@ -98,6 +98,8 @@ static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * sr
|
|||||||
/*If it's a PNG file in a C array...*/
|
/*If it's a PNG file in a C array...*/
|
||||||
else if(src_type == LV_IMG_SRC_VARIABLE) {
|
else if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||||
const lv_img_dsc_t * img_dsc = src;
|
const lv_img_dsc_t * img_dsc = src;
|
||||||
|
const uint8_t magic[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
|
||||||
|
if(memcmp(magic, img_dsc->data, sizeof(magic))) return LV_RES_INV;
|
||||||
header->always_zero = 0;
|
header->always_zero = 0;
|
||||||
header->cf = img_dsc->header.cf; /*Save the color format*/
|
header->cf = img_dsc->header.cf; /*Save the color format*/
|
||||||
header->w = img_dsc->header.w; /*Save the color width*/
|
header->w = img_dsc->header.w; /*Save the color width*/
|
||||||
|
|||||||
Reference in New Issue
Block a user