From 238947ce91a07fc4fbb17de0a140349446ff4898 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 29 Jun 2018 20:44:19 +0000 Subject: Remove out param from CCodec_IccModule::CreateTransform_sRGB(). Its return value contains the same data. Change-Id: I2bf4e72faf978e5d491bec573babc8099cda4e5a Reviewed-on: https://pdfium-review.googlesource.com/36633 Commit-Queue: Lei Zhang Reviewed-by: Henrique Nakashima --- core/fpdfapi/page/cpdf_iccprofile.cpp | 5 ++--- core/fxcodec/codec/ccodec_iccmodule.h | 3 +-- core/fxcodec/codec/fx_codec_icc.cpp | 14 ++++++-------- testing/fuzzers/pdf_codec_icc_fuzzer.cc | 5 ++--- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/core/fpdfapi/page/cpdf_iccprofile.cpp b/core/fpdfapi/page/cpdf_iccprofile.cpp index c0bf7cd2a2..ef1b9ef434 100644 --- a/core/fpdfapi/page/cpdf_iccprofile.cpp +++ b/core/fpdfapi/page/cpdf_iccprofile.cpp @@ -27,11 +27,10 @@ CPDF_IccProfile::CPDF_IccProfile(const CPDF_Stream* pStream, return; } - uint32_t nSrcComps = 0; auto* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); - m_Transform = pIccModule->CreateTransform_sRGB(pData, dwSize, &nSrcComps); + m_Transform = pIccModule->CreateTransform_sRGB(pData, dwSize); if (m_Transform) - m_nSrcComponents = nSrcComps; + m_nSrcComponents = m_Transform->components(); } CPDF_IccProfile::~CPDF_IccProfile() {} diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h index 38d9ec8686..419bf17777 100644 --- a/core/fxcodec/codec/ccodec_iccmodule.h +++ b/core/fxcodec/codec/ccodec_iccmodule.h @@ -46,8 +46,7 @@ class CCodec_IccModule { ~CCodec_IccModule(); std::unique_ptr CreateTransform_sRGB(const uint8_t* pProfileData, - uint32_t dwProfileSize, - uint32_t* nComponents); + uint32_t dwProfileSize); void Translate(CLcmsCmm* pTransform, const float* pSrcValues, float* pDestValues); diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index b2f2b4064d..fc82e043b4 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -51,9 +51,7 @@ CCodec_IccModule::~CCodec_IccModule() {} std::unique_ptr CCodec_IccModule::CreateTransform_sRGB( const unsigned char* pSrcProfileData, - uint32_t dwSrcProfileSize, - uint32_t* nSrcComponents) { - *nSrcComponents = 0; + uint32_t dwSrcProfileSize) { ScopedCmsProfile srcProfile( cmsOpenProfileFromMem(pSrcProfileData, dwSrcProfileSize)); if (!srcProfile) @@ -65,9 +63,9 @@ std::unique_ptr CCodec_IccModule::CreateTransform_sRGB( cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile.get()); - *nSrcComponents = cmsChannelsOf(srcCS); + uint32_t nSrcComponents = cmsChannelsOf(srcCS); // According to PDF spec, number of components must be 1, 3, or 4. - if (*nSrcComponents != 1 && *nSrcComponents != 3 && *nSrcComponents != 4) + if (nSrcComponents != 1 && nSrcComponents != 3 && nSrcComponents != 4) return nullptr; int srcFormat; @@ -75,11 +73,11 @@ std::unique_ptr CCodec_IccModule::CreateTransform_sRGB( bool bNormal = false; if (srcCS == cmsSigLabData) { srcFormat = - COLORSPACE_SH(PT_Lab) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(0); + COLORSPACE_SH(PT_Lab) | CHANNELS_SH(nSrcComponents) | BYTES_SH(0); bLab = true; } else { srcFormat = - COLORSPACE_SH(PT_ANY) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(1); + COLORSPACE_SH(PT_ANY) | CHANNELS_SH(nSrcComponents) | BYTES_SH(1); // TODO(thestig): Check to see if lcms2 supports more colorspaces that can // be considered normal. bNormal = srcCS == cmsSigGrayData || srcCS == cmsSigRgbData || @@ -107,7 +105,7 @@ std::unique_ptr CCodec_IccModule::CreateTransform_sRGB( if (!hTransform) return nullptr; - return pdfium::MakeUnique(hTransform, *nSrcComponents, bLab, + return pdfium::MakeUnique(hTransform, nSrcComponents, bLab, bNormal); } diff --git a/testing/fuzzers/pdf_codec_icc_fuzzer.cc b/testing/fuzzers/pdf_codec_icc_fuzzer.cc index 7021017953..2f4fa44662 100644 --- a/testing/fuzzers/pdf_codec_icc_fuzzer.cc +++ b/testing/fuzzers/pdf_codec_icc_fuzzer.cc @@ -8,16 +8,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { CCodec_IccModule icc_module; - uint32_t nComponent = 0; std::unique_ptr transform = - icc_module.CreateTransform_sRGB(data, size, &nComponent); + icc_module.CreateTransform_sRGB(data, size); if (transform) { float src[4]; float dst[4]; for (int i = 0; i < 4; i++) src[i] = 0.5f; - icc_module.SetComponents(nComponent); + icc_module.SetComponents(transform->components()); icc_module.Translate(transform.get(), src, dst); } -- cgit v1.2.3