diff options
Diffstat (limited to 'core/fxcodec/lgif')
-rw-r--r-- | core/fxcodec/lgif/cgifcontext.cpp | 3 | ||||
-rw-r--r-- | core/fxcodec/lgif/cgifcontext.h | 5 | ||||
-rw-r--r-- | core/fxcodec/lgif/fx_gif.cpp | 29 | ||||
-rw-r--r-- | core/fxcodec/lgif/fx_gif.h | 1 |
4 files changed, 12 insertions, 26 deletions
diff --git a/core/fxcodec/lgif/cgifcontext.cpp b/core/fxcodec/lgif/cgifcontext.cpp index b7a513c7e8..9c03cffa21 100644 --- a/core/fxcodec/lgif/cgifcontext.cpp +++ b/core/fxcodec/lgif/cgifcontext.cpp @@ -33,9 +33,8 @@ CGifContext::CGifContext(CCodec_GifModule* gif_module, char* error_string) CGifContext::~CGifContext() {} -void CGifContext::ThrowError(const char* err_msg) { +void CGifContext::AddError(const char* err_msg) { strncpy(err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1); - longjmp(jmpbuf, 1); } void CGifContext::RecordCurrentPosition(uint32_t* cur_pos_ptr) { diff --git a/core/fxcodec/lgif/cgifcontext.h b/core/fxcodec/lgif/cgifcontext.h index e65d6c7b0b..08a66c18e2 100644 --- a/core/fxcodec/lgif/cgifcontext.h +++ b/core/fxcodec/lgif/cgifcontext.h @@ -7,7 +7,6 @@ #ifndef CORE_FXCODEC_LGIF_CGIFCONTEXT_H_ #define CORE_FXCODEC_LGIF_CGIFCONTEXT_H_ -#include <setjmp.h> #include <memory> #include <vector> @@ -21,8 +20,7 @@ class CGifContext { CGifContext(CCodec_GifModule* gif_module, char* error_string); ~CGifContext(); - // TODO(npm): Remove longjmp from this method!!! - void ThrowError(const char* err_msg); + void AddError(const char* err_msg); void RecordCurrentPosition(uint32_t* cur_pos_ptr); void ReadScanline(int32_t row_num, uint8_t* row_buf); bool GetRecordPosition(uint32_t cur_pos, @@ -38,7 +36,6 @@ class CGifContext { int32_t disposal_method, bool interlace); - jmp_buf jmpbuf; std::vector<GifPalette> m_GlobalPalette; int32_t global_pal_num; uint32_t img_row_offset; diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp index 5e257cc2f5..b4fe328f6c 100644 --- a/core/fxcodec/lgif/fx_gif.cpp +++ b/core/fxcodec/lgif/fx_gif.cpp @@ -119,8 +119,7 @@ GifDecodeStatus gif_decode_extension(CGifContext* context) { GifDecodeStatus gif_decode_image_info(CGifContext* context) { if (context->width == 0 || context->height == 0) { - context->ThrowError("No Image Header Info"); - NOTREACHED(); + context->AddError("No Image Header Info"); return GifDecodeStatus::Error; } uint32_t skip_size_org = context->skip_size; @@ -143,9 +142,7 @@ GifDecodeStatus gif_decode_image_info(CGifContext* context) { context->width || gif_image->m_ImageInfo.top + gif_image->m_ImageInfo.height > context->height) { - gif_image = nullptr; - context->ThrowError("Image Data Out Of LSD, The File May Be Corrupt"); - NOTREACHED(); + context->AddError("Image Data Out Of LSD, The File May Be Corrupt"); return GifDecodeStatus::Error; } GifLF* gif_img_info_lf_ptr = (GifLF*)&gif_img_info_ptr->local_flag; @@ -182,8 +179,7 @@ void gif_decoding_failure_at_tail_cleanup(CGifContext* context, GifImage* gif_image_ptr) { gif_image_ptr->m_ImageRowBuf.clear(); gif_save_decoding_status(context, GIF_D_STATUS_TAIL); - context->ThrowError("Decode Image Data Error"); - NOTREACHED(); + context->AddError("Decode Image Data Error"); } } // namespace @@ -378,8 +374,7 @@ GifDecodeStatus gif_read_header(CGifContext* context) { if (strncmp(gif_header_ptr->signature, GIF_SIGNATURE, 3) != 0 || gif_header_ptr->version[0] != '8' || gif_header_ptr->version[2] != 'a') { - context->ThrowError("Not A Gif Image"); - NOTREACHED(); + context->AddError("Not A Gif Image"); return GifDecodeStatus::Error; } GifLSD* gif_lsd_ptr = nullptr; @@ -474,6 +469,7 @@ GifDecodeStatus gif_get_frame(CGifContext* context) { ret = gif_decode_image_info(context); if (ret != GifDecodeStatus::Success) return ret; + continue; } case GIF_D_STATUS_IMG_DATA: { @@ -517,8 +513,7 @@ GifDecodeStatus gif_load_frame(CGifContext* context, int32_t frame_num) { GifImage* gif_image_ptr = context->m_Images[frame_num].get(); uint32_t gif_img_row_bytes = gif_image_ptr->m_ImageInfo.width; if (gif_img_row_bytes == 0) { - context->ThrowError("Error Invalid Number of Row Bytes"); - NOTREACHED(); + context->AddError("Error Invalid Number of Row Bytes"); return GifDecodeStatus::Error; } if (context->decode_status == GIF_D_STATUS_TAIL) { @@ -541,8 +536,7 @@ GifDecodeStatus gif_load_frame(CGifContext* context, int32_t frame_num) { (bool)((GifLF*)&gif_image_ptr->m_ImageInfo.local_flag)->interlace); if (!bRes) { gif_image_ptr->m_ImageRowBuf.clear(); - context->ThrowError("Error Read Record Position Data"); - NOTREACHED(); + context->AddError("Error Read Record Position Data"); return GifDecodeStatus::Error; } } else { @@ -560,15 +554,13 @@ GifDecodeStatus gif_load_frame(CGifContext* context, int32_t frame_num) { (bool)((GifLF*)&gif_image_ptr->m_ImageInfo.local_flag)->interlace); if (!bRes) { gif_image_ptr->m_ImageRowBuf.clear(); - context->ThrowError("Error Read Record Position Data"); - NOTREACHED(); + context->AddError("Error Read Record Position Data"); return GifDecodeStatus::Error; } } if (gif_image_ptr->image_code_size >= 13) { gif_image_ptr->m_ImageRowBuf.clear(); - context->ThrowError("Error Invalid Code Size"); - NOTREACHED(); + context->AddError("Error Invalid Code Size"); return GifDecodeStatus::Error; } if (!context->m_ImgDecoder.get()) @@ -665,8 +657,7 @@ GifDecodeStatus gif_load_frame(CGifContext* context, int32_t frame_num) { } gif_save_decoding_status(context, GIF_D_STATUS_TAIL); } - context->ThrowError("Decode Image Data Error"); - NOTREACHED(); + context->AddError("Decode Image Data Error"); return GifDecodeStatus::Error; } diff --git a/core/fxcodec/lgif/fx_gif.h b/core/fxcodec/lgif/fx_gif.h index d7cd5d83fb..5216eeb70e 100644 --- a/core/fxcodec/lgif/fx_gif.h +++ b/core/fxcodec/lgif/fx_gif.h @@ -7,7 +7,6 @@ #ifndef CORE_FXCODEC_LGIF_FX_GIF_H_ #define CORE_FXCODEC_LGIF_FX_GIF_H_ -#include <setjmp.h> #include <memory> #include <vector> |