diff options
author | Nicolas Pena <npm@chromium.org> | 2017-05-11 15:43:47 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-11 20:01:33 +0000 |
commit | 0dc8571d1354b8c319510be625a446218449f532 (patch) | |
tree | fec012e29cd98f7565565cdc84d219709c7e1dd6 /core/fxcodec/lgif | |
parent | 830897a1774fb50d04b656d7bf70be321e133cf9 (diff) | |
download | pdfium-0dc8571d1354b8c319510be625a446218449f532.tar.xz |
Do not use vector data() when it is empty
Before, all pointers were being initialized to 0. After raw pointers were
changed to vectors, data() was used in some cases, but now no longer returns
nullptr when it is supposed to. This CL fixes that.
Bug: chromium:721417
Change-Id: Ia31b75b18dc17d7eed48538145fe5d0d59668843
Reviewed-on: https://pdfium-review.googlesource.com/5353
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fxcodec/lgif')
-rw-r--r-- | core/fxcodec/lgif/cgifdecompressor.cpp | 17 | ||||
-rw-r--r-- | core/fxcodec/lgif/fx_gif.cpp | 10 |
2 files changed, 22 insertions, 5 deletions
diff --git a/core/fxcodec/lgif/cgifdecompressor.cpp b/core/fxcodec/lgif/cgifdecompressor.cpp index 073659fd1c..6e9352f0af 100644 --- a/core/fxcodec/lgif/cgifdecompressor.cpp +++ b/core/fxcodec/lgif/cgifdecompressor.cpp @@ -18,7 +18,22 @@ FXGIF_Context::FXGIF_Context() {} FXGIF_Context::~FXGIF_Context() {} CGifDecompressor::CGifDecompressor(FXGIF_Context* p, char* error_string) - : decode_status(GIF_D_STATUS_SIG), err_ptr(error_string), gif_context(p) {} + : global_pal_num(0), + img_row_offset(0), + img_row_avail_size(0), + avail_in(0), + decode_status(GIF_D_STATUS_SIG), + skip_size(0), + err_ptr(error_string), + gif_context(p), + next_in(nullptr), + width(0), + height(0), + bc_index(0), + pixel_aspect(0), + global_sort_flag(0), + global_color_resolution(0), + img_pass_num(0) {} CGifDecompressor::~CGifDecompressor() {} diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp index e50e64a559..4248c88a01 100644 --- a/core/fxcodec/lgif/fx_gif.cpp +++ b/core/fxcodec/lgif/fx_gif.cpp @@ -510,12 +510,15 @@ GifDecodeStatus gif_load_frame(CGifDecompressor* gif_ptr, int32_t frame_num) { ? (2 << ((GifLF*)&gif_image_ptr->m_ImageInfo.local_flag)->pal_bits) : 0; gif_ptr->avail_in = 0; + GifPalette* pLocalPalette = gif_image_ptr->m_LocalPalettes.empty() + ? nullptr + : gif_image_ptr->m_LocalPalettes.data(); if (!gif_img_gce_ptr) { bool bRes = gif_ptr->GetRecordPosition( gif_image_ptr->image_data_pos, gif_image_ptr->m_ImageInfo.left, gif_image_ptr->m_ImageInfo.top, gif_image_ptr->m_ImageInfo.width, - gif_image_ptr->m_ImageInfo.height, loc_pal_num, - gif_image_ptr->m_LocalPalettes.data(), 0, 0, -1, 0, + gif_image_ptr->m_ImageInfo.height, loc_pal_num, pLocalPalette, 0, 0, + -1, 0, (bool)((GifLF*)&gif_image_ptr->m_ImageInfo.local_flag)->interlace); if (!bRes) { gif_image_ptr->m_ImageRowBuf.clear(); @@ -526,8 +529,7 @@ GifDecodeStatus gif_load_frame(CGifDecompressor* gif_ptr, int32_t frame_num) { bool bRes = gif_ptr->GetRecordPosition( gif_image_ptr->image_data_pos, gif_image_ptr->m_ImageInfo.left, gif_image_ptr->m_ImageInfo.top, gif_image_ptr->m_ImageInfo.width, - gif_image_ptr->m_ImageInfo.height, loc_pal_num, - gif_image_ptr->m_LocalPalettes.data(), + gif_image_ptr->m_ImageInfo.height, loc_pal_num, pLocalPalette, (int32_t)gif_image_ptr->m_ImageGCE->delay_time, (bool)((GifCEF*)&gif_image_ptr->m_ImageGCE->gce_flag)->user_input, ((GifCEF*)&gif_image_ptr->m_ImageGCE->gce_flag)->transparency |