From 04011bedfff8b4d5e9a123619c431263ec280072 Mon Sep 17 00:00:00 2001 From: aussa Date: Mon, 10 Aug 2026 18:19:00 +0200 Subject: [PATCH 1/4] remove redundant NaN checks in binary reader and improve error reporting for memory stream bounds violations --- src/processing/binary/reader.cpp | 8 ++------ src/processing/stream/memory_stream.cpp | 11 ++++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/processing/binary/reader.cpp b/src/processing/binary/reader.cpp index 77deb62..677d59d 100644 --- a/src/processing/binary/reader.cpp +++ b/src/processing/binary/reader.cpp @@ -1,4 +1,3 @@ -#include #include #include "esfa/processing/binary/reader.hpp" @@ -128,7 +127,7 @@ uint64_t Reader::ReadUInt64() float Reader::ReadSingle() { - float result; + float result = 0.f; stream->Read((char*)&result, sizeof(float)); @@ -146,7 +145,7 @@ float Reader::ReadSingle() double Reader::ReadDouble() { - double result = NAN; + double result = 0.0; stream->Read((char*)&result, sizeof(double)); @@ -160,9 +159,6 @@ double Reader::ReadDouble() result = tmp; } - if (std::isnan(result)) - throw std::runtime_error("Reader::ReadDouble(): Error reading stream"); - return result; } diff --git a/src/processing/stream/memory_stream.cpp b/src/processing/stream/memory_stream.cpp index 0e0be41..026d585 100644 --- a/src/processing/stream/memory_stream.cpp +++ b/src/processing/stream/memory_stream.cpp @@ -67,13 +67,10 @@ void MemoryStream::Read(char* dest, size_t length) } if (mPosition + length > mBuffer.size()) { - std::string msg = - "MemoryStream::Read: position " + std::to_string(mPosition) + - " + length " + std::to_string(length) + - " = " + std::to_string(mPosition + length) + - " > buffer size " + std::to_string(mBuffer.size()); - - throw std::runtime_error(msg); + throw std::runtime_error( + "MemoryStream::Read: short read (past end of buffer) pos=" + + std::to_string(mPosition) + " len=" + std::to_string(length) + + " size=" + std::to_string(mBuffer.size())); } std::memcpy(dest, mBuffer.data() + mPosition, length); mPosition += length; From 3da3c9f2913eecd3b25c2d8613e09cd9cc06bddb Mon Sep 17 00:00:00 2001 From: aussa Date: Thu, 13 Aug 2026 19:56:17 +0200 Subject: [PATCH 2/4] add ci --- .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9448107 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +name: runTests + +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: + +jobs: + build-and-test: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y cmake ninja-build + + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install cmake ninja + + - name: Configure (Linux / macOS) + if: runner.os != 'Windows' + run: | + cmake -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DESFA_BUILD_TESTS=ON + + - name: Configure (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + cmake -B build ` + -DCMAKE_BUILD_TYPE=Release ` + -DESFA_BUILD_TESTS=ON + + - name: Build (Linux / macOS) + if: runner.os != 'Windows' + run: cmake --build build + + - name: Build (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: cmake --build build --config Release + + - name: Test (Linux / macOS) + if: runner.os != 'Windows' + run: ctest --test-dir build/test --output-on-failure + + - name: Test (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: ctest --test-dir build/test --build-config Release --output-on-failure From d4a53d96ada6a317b536065b25d86e5e2028e0f7 Mon Sep 17 00:00:00 2001 From: aussa Date: Thu, 13 Aug 2026 19:56:33 +0200 Subject: [PATCH 3/4] update Processor --- include/esfa/esfa.hpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/include/esfa/esfa.hpp b/include/esfa/esfa.hpp index 190d513..fbde7f3 100644 --- a/include/esfa/esfa.hpp +++ b/include/esfa/esfa.hpp @@ -8,15 +8,9 @@ namespace esfa { class Processor { public: - explicit Processor(const interface::Registry& registry) - : mRegistry(registry) - { - } - - const interface::Registry& GetRegistry() - { - return mRegistry; - } + explicit Processor(const interface::Registry& registry) : mRegistry(registry) {} + + const interface::Registry& GetRegistry() const { return mRegistry; } std::shared_ptr ParseAsset( const std::string& typeKey, From 5ff65dcda00fe4fff03cc100e945e79932885fb9 Mon Sep 17 00:00:00 2001 From: aussa Date: Thu, 13 Aug 2026 19:58:47 +0200 Subject: [PATCH 4/4] fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9448107..de8caaa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: runTests on: push: - branches: [ main ] + branches: [ master, main ] pull_request: workflow_dispatch: