mm_util_retvm_if((fileread < JPG_HEADER_TYPE_LENGTH), ret, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
if (header_type[0] != 0xFF) {
- mm_util_warn("Failed to get w / h from jpeg at index [%d]", i);
- break;
+ mm_util_warn("Failed to get w / h from jpeg at index [%d] and go to next block.", i);
+ /* add error handling when jpeg image has junk data in header */
+ block_length = JPG_HEADER_TYPE_LENGTH;
+ continue;
}
if (header_type[1] == 0xC0 || header_type[1] == 0xC2) {
*pHeight = image_size[3] * 256 + image_size[4];
break;
} else {
- i += 2;
+ i += JPG_HEADER_TYPE_LENGTH;
memset(block_size, 0, JPG_BLOCK_SIZE_LENGTH);
fileread = fread(block_size, sizeof(char), JPG_BLOCK_SIZE_LENGTH, hFile);
mm_util_retvm_if((fileread < JPG_BLOCK_SIZE_LENGTH), ret, "IMG_CODEC_UNKNOWN_TYPE in JPEG");