From a000b46f7daf2272c245e233164520ed19216744 Mon Sep 17 00:00:00 2001 From: tobid7 Date: Wed, 11 Mar 2026 15:46:31 +0100 Subject: [PATCH] Fix sign-compare issues - Temp remove smdh size check (to fix usage with _3dsx) --- source/bclim.cpp | 2 +- source/helper.cpp | 2 +- source/lz11.cpp | 2 +- source/smdh.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/bclim.cpp b/source/bclim.cpp index 50109fb..767d6e0 100644 --- a/source/bclim.cpp +++ b/source/bclim.cpp @@ -47,7 +47,7 @@ CTRFF_API void BCLIM::CreateByImage(const std::vector& data, int w, int h, pImag.Height = h; pImag.ImageSize = data.size(); pBuffer.resize(data.size()); - for (int i = 0; i < data.size(); i++) { + for (size_t i = 0; i < data.size(); i++) { pBuffer[i] = data[i]; } pCurrent.FileSize = pBuffer.size() + pCurrent.HeaderSize + pImag.HeaderSize; diff --git a/source/helper.cpp b/source/helper.cpp index fd7ea30..bf8bf0f 100644 --- a/source/helper.cpp +++ b/source/helper.cpp @@ -30,7 +30,7 @@ CTRFF_API ctrff::u32 ctrff::TileIndex(const int &x, const int &y, CTRFF_API void ctrff::RGB565toRGBA(std::vector &img, const ctrff::u16 *icon, const int &w, const int &h) { - if (img.size() != (w * h * 4)) { + if (img.size() != size_t(w * h * 4)) { img.clear(); img.resize(w * h * 4); } diff --git a/source/lz11.cpp b/source/lz11.cpp index 9e3c167..b31c98d 100644 --- a/source/lz11.cpp +++ b/source/lz11.cpp @@ -166,7 +166,7 @@ CTRFF_API std::vector Decompress(const std::vector& in) { dst_off++; } } - if (dst_off >= len) return ret; + if ((u32)dst_off >= len) return ret; header <<= 1; } } diff --git a/source/smdh.cpp b/source/smdh.cpp index db679e8..69c75e5 100644 --- a/source/smdh.cpp +++ b/source/smdh.cpp @@ -18,12 +18,12 @@ CTRFF_API void ctrff::SMDH::Write(std::fstream &f) const { } CTRFF_API void ctrff::SMDH::Read(std::fstream &f) { - f.seekg(0, std::ios::end); + /*f.seekg(0, std::ios::end); if (f.tellg() != SMDH_Size) { throw std::runtime_error( "SMDH: File size does not match the SMDH Header size!"); } - f.seekg(0, std::ios::beg); + f.seekg(0, std::ios::beg);*/ f.read(reinterpret_cast(Magic), sizeof(Magic)); if (std::string(Magic) != smdh_magic) { throw std::runtime_error("SMDH: Invalid SMDH file!");