From e1a7e8589a8cb4fc8a8052819742bdb0bac91a52 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 10 Aug 2018 16:29:19 +0000 Subject: Remove const_cast<> from CFX_LZWDecompressor::Decode() caller. Because the argument to Decode() can be const. Part of the ongoing war against const_cast<>. Change-Id: I3a8402277dbfc4fd80b1dd60225de57b732713f8 Reviewed-on: https://pdfium-review.googlesource.com/39832 Reviewed-by: Ryan Harrison Commit-Queue: Tom Sepez --- core/fxcodec/gif/cfx_lzwdecompressor.cpp | 2 +- core/fxcodec/gif/cfx_lzwdecompressor.h | 5 ++--- testing/fuzzers/pdf_lzw_fuzzer.cc | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.cpp b/core/fxcodec/gif/cfx_lzwdecompressor.cpp index d4fd43d321..a23106bb37 100644 --- a/core/fxcodec/gif/cfx_lzwdecompressor.cpp +++ b/core/fxcodec/gif/cfx_lzwdecompressor.cpp @@ -42,7 +42,7 @@ CFX_LZWDecompressor::CFX_LZWDecompressor(uint8_t color_exp, uint8_t code_exp) CFX_LZWDecompressor::~CFX_LZWDecompressor() {} -CFX_GifDecodeStatus CFX_LZWDecompressor::Decode(uint8_t* src_buf, +CFX_GifDecodeStatus CFX_LZWDecompressor::Decode(const uint8_t* src_buf, uint32_t src_size, uint8_t* dest_buf, uint32_t* dest_size) { diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.h b/core/fxcodec/gif/cfx_lzwdecompressor.h index 808f50a7cf..f4df065e34 100644 --- a/core/fxcodec/gif/cfx_lzwdecompressor.h +++ b/core/fxcodec/gif/cfx_lzwdecompressor.h @@ -24,7 +24,7 @@ class CFX_LZWDecompressor { uint8_t code_exp); ~CFX_LZWDecompressor(); - CFX_GifDecodeStatus Decode(uint8_t* src_buf, + CFX_GifDecodeStatus Decode(const uint8_t* src_buf, uint32_t src_size, uint8_t* dest_buf, uint32_t* dest_size); @@ -35,7 +35,6 @@ class CFX_LZWDecompressor { } std::vector* DecompressedForTest() { return &decompressed_; } - size_t* DecompressedNextForTest() { return &decompressed_next_; } private: @@ -55,7 +54,7 @@ class CFX_LZWDecompressor { std::vector decompressed_; size_t decompressed_next_; uint16_t code_old_; - uint8_t* next_in_; + const uint8_t* next_in_; uint32_t avail_in_; uint8_t bits_left_; uint32_t code_store_; diff --git a/testing/fuzzers/pdf_lzw_fuzzer.cc b/testing/fuzzers/pdf_lzw_fuzzer.cc index 7e10d2a1ee..e4d993e821 100644 --- a/testing/fuzzers/pdf_lzw_fuzzer.cc +++ b/testing/fuzzers/pdf_lzw_fuzzer.cc @@ -28,9 +28,9 @@ void LZWFuzz(const uint8_t* src_buf, // the initial data. uint32_t dest_size = static_cast(dest_buf.size()); if (CFX_GifDecodeStatus::InsufficientDestSize != - decompressor->Decode(const_cast(src_buf), src_size, - dest_buf.data(), &dest_size)) + decompressor->Decode(src_buf, src_size, dest_buf.data(), &dest_size)) { return; + } } } -- cgit v1.2.3