diff --git a/.github/workflows/sanitize.yml b/.github/workflows/sanitize.yml index 010119c1..530b76b3 100644 --- a/.github/workflows/sanitize.yml +++ b/.github/workflows/sanitize.yml @@ -11,22 +11,17 @@ env: jobs: build: - name: ${{ matrix.config.name }} + name: ${{ matrix.sanitizer.name }} (${{ matrix.compiler.cc }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: - config: - - { - name: "Address Sanitizer", - sanitize: "address", - cc: "gcc", cxx: "g++" - } - - { - name: "Undefined Behavior Sanitizer", - sanitize: "undefined,float-cast-overflow", - cc: "clang", cxx: "clang++" - } + sanitizer: + - { name: "Address Sanitizer", flags: "address" } + - { name: "Undefined Behavior Sanitizer", flags: "undefined,float-cast-overflow" } + compiler: + - { cc: "gcc", cxx: "g++" } + - { cc: "clang", cxx: "clang++" } env: UBSAN_OPTIONS: print_stacktrace=1 @@ -38,9 +33,9 @@ jobs: persist-credentials: false - name: Configure env: - CC: ${{ matrix.config.cc }} - CXX: ${{ matrix.config.cxx }} - run: cmake -B build -S . -DSANITIZE=${{ matrix.config.sanitize }} + CC: ${{ matrix.compiler.cc }} + CXX: ${{ matrix.compiler.cxx }} + run: cmake -B build -S . -DSANITIZE=${{ matrix.sanitizer.flags }} - name: Build C++ unit tests run: cmake --build build --config Release - name: Run C++ tests diff --git a/common/include/memory_operations.hpp b/common/include/memory_operations.hpp index e5cc058d..0fab58a1 100644 --- a/common/include/memory_operations.hpp +++ b/common/include/memory_operations.hpp @@ -44,13 +44,13 @@ static inline void check_memory_size(size_t requested_index, size_t capacity) { // note: size is in bytes, not items static inline size_t copy_from_mem(const void* src, void* dst, size_t size) { - memcpy(dst, src, size); + if (size > 0) memcpy(dst, src, size); return size; } // note: size is in bytes, not items static inline size_t copy_to_mem(const void* src, void* dst, size_t size) { - memcpy(dst, src, size); + if (size > 0) memcpy(dst, src, size); return size; }