Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: core/fxcodec/lgif/fx_gif.cpp

Issue 2230683002: fix 617135 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: FX_ArraySize and cleanup helper method Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxcodec/lgif/fx_gif.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcodec/lgif/fx_gif.cpp
diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp
index d6db28b427373ab601e767a25ed1d73afd22a925..b94445ccf3eee7d8a710c9ebf9f5865cbc2e36e4 100644
--- a/core/fxcodec/lgif/fx_gif.cpp
+++ b/core/fxcodec/lgif/fx_gif.cpp
@@ -925,10 +925,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
gif_image_ptr->image_row_buf + gif_ptr->img_row_offset,
gif_ptr->img_row_avail_size);
if (ret == 0) {
- FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = nullptr;
- gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
- gif_error(gif_ptr, "Decode Image Data Error");
+ gif_decoding_failure_at_tail_cleanup(gif_ptr, gif_image_ptr);
return 0;
}
while (ret != 0) {
@@ -970,6 +967,10 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
if (gif_image_ptr->image_row_num >=
(int32_t)gif_image_ptr->image_info_ptr->height) {
gif_ptr->img_pass_num++;
+ if (gif_ptr->img_pass_num == FX_ArraySize(s_gif_interlace_step)) {
+ gif_decoding_failure_at_tail_cleanup(gif_ptr, gif_image_ptr);
+ return 0;
+ }
gif_image_ptr->image_row_num =
s_gif_interlace_step[gif_ptr->img_pass_num] / 2;
}
@@ -984,10 +985,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
gif_ptr->img_row_avail_size);
}
if (ret == 0) {
- FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = nullptr;
- gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
- gif_error(gif_ptr, "Decode Image Data Error");
+ gif_decoding_failure_at_tail_cleanup(gif_ptr, gif_image_ptr);
return 0;
}
}
@@ -997,6 +995,13 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
gif_error(gif_ptr, "Decode Image Data Error");
return 0;
}
+void gif_decoding_failure_at_tail_cleanup(gif_decompress_struct_p gif_ptr,
+ GifImage* gif_image_ptr) {
+ FX_Free(gif_image_ptr->image_row_buf);
+ gif_image_ptr->image_row_buf = nullptr;
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
+ gif_error(gif_ptr, "Decode Image Data Error");
+}
void gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status) {
gif_ptr->decode_status = status;
gif_ptr->next_in += gif_ptr->skip_size;
« no previous file with comments | « core/fxcodec/lgif/fx_gif.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698