From 875e98c581952478f3a3ccef9b2f2e3ed06c5346 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 27 Sep 2017 10:53:11 -0400 Subject: Remove FX_STRSIZE and replace with size_t BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair Commit-Queue: Ryan Harrison --- core/fxcodec/codec/ccodec_jpegmodule.h | 2 +- core/fxcodec/codec/ccodec_pngmodule.cpp | 8 +++++--- core/fxcodec/codec/ccodec_tiffmodule.cpp | 8 ++++---- core/fxcodec/codec/fx_codec_jpeg.cpp | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) (limited to 'core/fxcodec/codec') diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h index cc59924747..ca561317aa 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.h +++ b/core/fxcodec/codec/ccodec_jpegmodule.h @@ -60,7 +60,7 @@ class CCodec_JpegModule { #if _FX_OS_ == _FX_OS_WIN32_ || _FX_OS_ == _FX_OS_WIN64_ static bool JpegEncode(const RetainPtr& pSource, uint8_t** dest_buf, - FX_STRSIZE* dest_size); + size_t* dest_size); #endif }; diff --git a/core/fxcodec/codec/ccodec_pngmodule.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp index a08e72f86d..d500745ca7 100644 --- a/core/fxcodec/codec/ccodec_pngmodule.cpp +++ b/core/fxcodec/codec/ccodec_pngmodule.cpp @@ -74,7 +74,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr, #endif #if defined(PNG_TEXT_SUPPORTED) int i; - FX_STRSIZE len; + size_t len; const char* buf; int num_text; png_textp text = nullptr; @@ -86,8 +86,10 @@ static void _png_load_bmp_attribute(png_structp png_ptr, buf = "Author"; if (!memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) { pAttribute->m_strAuthor = - ByteString(reinterpret_cast(text[i].text), - static_cast(text[i].text_length)); + text[i].text_length > 0 + ? ByteString(reinterpret_cast(text[i].text), + static_cast(text[i].text_length)) + : ByteString(); } } } diff --git a/core/fxcodec/codec/ccodec_tiffmodule.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp index 07d189200e..f11c480bd7 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.cpp +++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp @@ -81,15 +81,15 @@ void* _TIFFrealloc(void* ptr, tmsize_t size) { } void _TIFFmemset(void* ptr, int val, tmsize_t size) { - memset(ptr, val, (size_t)size); + memset(ptr, val, static_cast(size)); } void _TIFFmemcpy(void* des, const void* src, tmsize_t size) { - memcpy(des, src, (size_t)size); + memcpy(des, src, static_cast(size)); } int _TIFFmemcmp(const void* ptr1, const void* ptr2, tmsize_t size) { - return memcmp(ptr1, ptr2, (size_t)size); + return memcmp(ptr1, ptr2, static_cast(size)); } int _TIFFIfMultiplicationOverflow(tmsize_t op1, tmsize_t op2) { @@ -201,7 +201,7 @@ void Tiff_Exif_GetStringInfo(TIFF* tif_ctx, TIFFGetField(tif_ctx, tag, &buf); if (!buf) return; - FX_STRSIZE size = FXSYS_strlen(buf); + size_t size = FXSYS_strlen(buf); uint8_t* ptr = FX_Alloc(uint8_t, size + 1); memcpy(ptr, buf, size); ptr[size] = 0; diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index b77fc87394..b1dffbb210 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -369,7 +369,7 @@ static void _error_fatal1(j_common_ptr cinfo) { } static void _src_skip_data1(struct jpeg_decompress_struct* cinfo, long num) { - if (cinfo->src->bytes_in_buffer < (size_t)num) { + if (cinfo->src->bytes_in_buffer < static_cast(num)) { auto* pContext = reinterpret_cast(cinfo->client_data); pContext->m_SkipSize = (unsigned int)(num - cinfo->src->bytes_in_buffer); cinfo->src->bytes_in_buffer = 0; @@ -510,7 +510,7 @@ uint32_t CCodec_JpegModule::GetAvailInput(Context* pContext, #define JPEG_BLOCK_SIZE 1048576 bool CCodec_JpegModule::JpegEncode(const RetainPtr& pSource, uint8_t** dest_buf, - FX_STRSIZE* dest_size) { + size_t* dest_size) { struct jpeg_error_mgr jerr; jerr.error_exit = _error_do_nothing; jerr.emit_message = _error_do_nothing1; @@ -603,7 +603,7 @@ bool CCodec_JpegModule::JpegEncode(const RetainPtr& pSource, jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); FX_Free(line_buf); - *dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; + *dest_size = dest_buf_length - static_cast(dest.free_in_buffer); return true; } -- cgit v1.2.3