From 9a7503b7c5168c59ba40491fae7ae79bcdd6b173 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Mon, 25 Mar 2024 14:57:54 +0100 Subject: [PATCH] fix warnings reported by CodeQL (#96) * fix code-issues reported by CodeQL * add to changelog --- CMakeLists.txt | 2 +- Src/JxrDecode/jxrlib/image/encode/strenc.c | 4 ++-- Src/JxrDecode/jxrlib/jxrgluelib/JXRGlue.c | 4 ++-- Src/JxrDecode/jxrlib/jxrgluelib/JXRGlueJxr.c | 4 ++-- Src/libCZI/Doc/version-history.markdown | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6251f9..325f2c3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15) cmake_policy(SET CMP0091 NEW) # enable new "MSVC runtime library selection" (https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) project(libCZI - VERSION 0.58.1 + VERSION 0.58.2 HOMEPAGE_URL "https://github.com/ZEISS/libczi" DESCRIPTION "libCZI is an Open Source Cross-Platform C++ library to read and write CZI") diff --git a/Src/JxrDecode/jxrlib/image/encode/strenc.c b/Src/JxrDecode/jxrlib/image/encode/strenc.c index c11b0456..7c1cae77 100644 --- a/Src/JxrDecode/jxrlib/image/encode/strenc.c +++ b/Src/JxrDecode/jxrlib/image/encode/strenc.c @@ -146,7 +146,7 @@ Int writeTileHeaderLP(CWMImageStrCodec* pSC, BitIOInfo* pIO) for (i = 0; i < pTile->cNumQPLP; i++) { pTile->cChModeLP[i] = (U8)(rand() & 3); // channel mode, just for concept proofing! - for (j = 0; j < pSC->m_param.cNumChannels; j++) + for (j = 0; j < (U8)pSC->m_param.cNumChannels; j++) pTile->pQuantizerLP[j][i].iIndex = (U8)((rand() & 0xfe) + 1); // QP indexes, just for concept proofing! formatQuantizer(pTile->pQuantizerLP, pTile->cChModeLP[i], pSC->m_param.cNumChannels, i, TRUE, pSC->m_param.bScaledArith); writeQuantizer(pTile->pQuantizerLP, pIO, pTile->cChModeLP[i], pSC->m_param.cNumChannels, i); @@ -189,7 +189,7 @@ Int writeTileHeaderHP(CWMImageStrCodec* pSC, BitIOInfo* pIO) for (i = 0; i < pTile->cNumQPHP; i++) { pTile->cChModeHP[i] = (U8)(rand() & 3); // channel mode, just for concept proofing! - for (j = 0; j < pSC->m_param.cNumChannels; j++) + for (j = 0; j < (U8)pSC->m_param.cNumChannels; j++) pTile->pQuantizerHP[j][i].iIndex = (U8)((rand() & 0xfe) + 1); // QP indexes, just for concept proofing! formatQuantizer(pTile->pQuantizerHP, pTile->cChModeHP[i], pSC->m_param.cNumChannels, i, FALSE, pSC->m_param.bScaledArith); writeQuantizer(pTile->pQuantizerHP, pIO, pTile->cChModeHP[i], pSC->m_param.cNumChannels, i); diff --git a/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlue.c b/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlue.c index e17fd02d..fd5f8b25 100644 --- a/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlue.c +++ b/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlue.c @@ -678,7 +678,7 @@ ERR PKImageEncode_WriteSource( cbStride = cbStrideFrom > cbStrideTo ? cbStrideFrom : cbStrideTo;// max(cbStrideFrom, cbStrideTo); // actual dec/enc with local buffer - Call(PKAllocAligned((void**)&pb, cbStride * pRect->Height, 128)); + Call(PKAllocAligned((void**)&pb, (size_t)cbStride * pRect->Height, 128)); Call(pFC->Copy(pFC, pRect, pb, cbStride)); @@ -779,7 +779,7 @@ ERR PKImageEncode_Transcode( else { // actual dec/enc with local buffer - Call(PKAllocAligned((void**)&pb, cbStride * pRect->Height, 128)); + Call(PKAllocAligned((void**)&pb, (size_t)cbStride * pRect->Height, 128)); Call(pFC->Copy(pFC, pRect, pb, cbStride)); Call(pIE->WritePixels(pIE, pRect->Height, pb, cbStride)); } diff --git a/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlueJxr.c b/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlueJxr.c index b005c40c..95c3d442 100644 --- a/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlueJxr.c +++ b/Src/JxrDecode/jxrlib/jxrgluelib/JXRGlueJxr.c @@ -2050,7 +2050,7 @@ ERR PKImageDecode_Copy_WMP( wmiBI.pv = pbLowMemAdj; // If we're past the top of the image, then we're done, so terminate. - if (linesperMBRow * (cMBRow - 1) >= (U32)pID->WMP.cLinesCropped + pID->WMP.wmiI.cROIHeight) { + if (linesperMBRow * (size_t)(cMBRow - 1) >= pID->WMP.cLinesCropped + pID->WMP.wmiI.cROIHeight) { FailIf(ICERR_OK != ImageStrDecTerm(pID->WMP.ctxSC), WMP_errFail); } pID->WMP.DecoderCurrMBRow = cMBRow; // Set to next possible MBRow that is decodable @@ -2132,7 +2132,7 @@ ERR PKImageDecode_Copy_WMP( } // If we're past the top of the image, then we're done, so terminate - if (linesperMBRow * (cMBRow - 1) >= (U32)pID->WMP.cLinesCropped + pID->WMP.wmiI.cROIHeight) { + if (linesperMBRow * (size_t)(cMBRow - 1) >= pID->WMP.cLinesCropped + pID->WMP.wmiI.cROIHeight) { FailIf(ICERR_OK != ImageStrDecTerm(pID->WMP.ctxSC_Alpha), WMP_errFail); } pID->WMP.DecoderCurrAlphaMBRow = cMBRow; // Set to next possible MBRow that is decodable diff --git a/Src/libCZI/Doc/version-history.markdown b/Src/libCZI/Doc/version-history.markdown index ca025360..24754e7e 100644 --- a/Src/libCZI/Doc/version-history.markdown +++ b/Src/libCZI/Doc/version-history.markdown @@ -17,4 +17,5 @@ version history {#version_history} 0.57.2 | [90](https://github.com/ZEISS/libczi/pull/90) | improve thread-safety of CziReader 0.57.3 | [91](https://github.com/ZEISS/libczi/pull/91) | improve error-message 0.58.0 | [92](https://github.com/ZEISS/libczi/pull/92) | export a list with properties for streams-property-bag - 0.58.1 | [95](https://github.com/ZEISS/libczi/pull/95) | some fixes for CziReaderWriter \ No newline at end of file + 0.58.1 | [95](https://github.com/ZEISS/libczi/pull/95) | some fixes for CziReaderWriter + 0.58.2 | [95](https://github.com/ZEISS/libczi/pull/96) | small fixes for deficiencies reported by CodeQL \ No newline at end of file