summaryrefslogtreecommitdiff
path: root/core/fxcodec/lbmp/fx_bmp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/lbmp/fx_bmp.cpp')
-rw-r--r--core/fxcodec/lbmp/fx_bmp.cpp54
1 files changed, 26 insertions, 28 deletions
diff --git a/core/fxcodec/lbmp/fx_bmp.cpp b/core/fxcodec/lbmp/fx_bmp.cpp
index f445453c65..e705555522 100644
--- a/core/fxcodec/lbmp/fx_bmp.cpp
+++ b/core/fxcodec/lbmp/fx_bmp.cpp
@@ -33,8 +33,7 @@ uint16_t GetWord_LSBFirst(uint8_t* p) {
}
BMPDecompressor::BMPDecompressor()
- : err_ptr(nullptr),
- context_ptr(nullptr),
+ : context_ptr(nullptr),
next_in(nullptr),
header_offset(0),
width(0),
@@ -64,8 +63,7 @@ BMPDecompressor::BMPDecompressor()
BMPDecompressor::~BMPDecompressor() {}
-void BMPDecompressor::Error(const char* err_msg) {
- strncpy(err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1);
+void BMPDecompressor::Error() {
longjmp(jmpbuf, 1);
}
@@ -96,7 +94,7 @@ int32_t BMPDecompressor::ReadHeader() {
data_size =
FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&pBmp_header->bfSize));
if (pBmp_header->bfType != BMP_SIGNATURE) {
- Error("Not A Bmp Image");
+ Error();
NOTREACHED();
}
if (avail_in < sizeof(uint32_t)) {
@@ -181,12 +179,12 @@ int32_t BMPDecompressor::ReadHeader() {
if (compress_flag == BMP_RGB && biPlanes == 1 && color_used == 0)
break;
}
- Error("Unsupported Bmp File");
+ Error();
NOTREACHED();
}
}
if (width > BMP_MAX_WIDTH || compress_flag > BMP_BITFIELDS) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
switch (bitCounts) {
@@ -196,14 +194,14 @@ int32_t BMPDecompressor::ReadHeader() {
case 16:
case 24: {
if (color_used > 1U << bitCounts) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
}
case 32:
break;
default:
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
src_row_bytes = BMP_WIDTHBYTES(width, bitCounts);
@@ -227,7 +225,7 @@ int32_t BMPDecompressor::ReadHeader() {
out_row_buffer.clear();
if (out_row_bytes <= 0) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
@@ -238,7 +236,7 @@ int32_t BMPDecompressor::ReadHeader() {
skip_size_org = skip_size;
if (compress_flag == BMP_BITFIELDS) {
if (bitCounts != 16 && bitCounts != 32) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
uint32_t* mask;
@@ -252,7 +250,7 @@ int32_t BMPDecompressor::ReadHeader() {
mask_blue = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[2]));
if (mask_red & mask_green || mask_red & mask_blue ||
mask_green & mask_blue) {
- Error("The Bitfield Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
header_offset = std::max(header_offset, 26 + img_ifh_size);
@@ -314,14 +312,14 @@ int32_t BMPDecompressor::DecodeImage() {
avail_in = 0;
if (!GetDataPosition(header_offset)) {
decode_status = BMP_D_STATUS_TAIL;
- Error("The Bmp File Is Corrupt, Unexpected Stream Offset");
+ Error();
NOTREACHED();
}
row_num = 0;
SaveDecodingStatus(BMP_D_STATUS_DATA);
}
if (decode_status != BMP_D_STATUS_DATA || !ValidateFlag()) {
- Error("Any Uncontrol Error");
+ Error();
NOTREACHED();
}
switch (compress_flag) {
@@ -339,7 +337,7 @@ int32_t BMPDecompressor::DecodeImage() {
bool BMPDecompressor::ValidateColorIndex(uint8_t val) {
if (val >= pal_num) {
- Error("A color index exceeds range determined by pal_num");
+ Error();
NOTREACHED();
}
return true;
@@ -433,7 +431,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
case RLE_EOL: {
if (row_num >= height) {
SaveDecodingStatus(BMP_D_STATUS_TAIL);
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
@@ -460,7 +458,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
col_num += delta_ptr[0];
size_t bmp_row_num_next = row_num + delta_ptr[1];
if (col_num >= out_row_bytes || bmp_row_num_next >= height) {
- Error("The Bmp File Is Corrupt Or Not Supported");
+ Error();
NOTREACHED();
}
while (row_num < bmp_row_num_next) {
@@ -473,7 +471,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size ||
static_cast<int32_t>(*first_byte_ptr) > avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
if (!ReadData(&second_byte_ptr, *first_byte_ptr & 1
@@ -495,7 +493,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
default: {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size || static_cast<int32_t>(*first_byte_ptr) > avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
if (!ReadData(&second_byte_ptr, 1)) {
@@ -511,7 +509,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
}
}
}
- Error("Any Uncontrol Error");
+ Error();
NOTREACHED();
}
@@ -534,7 +532,7 @@ int32_t BMPDecompressor::DecodeRLE4() {
case RLE_EOL: {
if (row_num >= height) {
SaveDecodingStatus(BMP_D_STATUS_TAIL);
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
@@ -561,7 +559,7 @@ int32_t BMPDecompressor::DecodeRLE4() {
col_num += delta_ptr[0];
size_t bmp_row_num_next = row_num + delta_ptr[1];
if (col_num >= out_row_bytes || bmp_row_num_next >= height) {
- Error("The Bmp File Is Corrupt Or Not Supported");
+ Error();
NOTREACHED();
}
while (row_num < bmp_row_num_next) {
@@ -573,13 +571,13 @@ int32_t BMPDecompressor::DecodeRLE4() {
default: {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
uint8_t size = HalfRoundUp(*first_byte_ptr);
if (static_cast<int32_t>(*first_byte_ptr) > avail_size) {
if (size + (col_num >> 1) > src_row_bytes) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
*first_byte_ptr = avail_size - 1;
@@ -602,13 +600,13 @@ int32_t BMPDecompressor::DecodeRLE4() {
default: {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
if (static_cast<int32_t>(*first_byte_ptr) > avail_size) {
uint8_t size = HalfRoundUp(*first_byte_ptr);
if (size + (col_num >> 1) > src_row_bytes) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
*first_byte_ptr = avail_size - 1;
@@ -628,7 +626,7 @@ int32_t BMPDecompressor::DecodeRLE4() {
}
}
}
- Error("Any Uncontrol Error");
+ Error();
NOTREACHED();
}
@@ -669,7 +667,7 @@ void BMPDecompressor::SetHeight(int32_t signed_height) {
return;
}
if (signed_height == std::numeric_limits<int>::min()) {
- Error("Unsupported height");
+ Error();
NOTREACHED();
}
height = -signed_height;