You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by ti...@apache.org on 2026/10/14 15:01:43 UTC

(datasketches-cpp) branch master updated: fix: Undefined behavior (#548)

This is an automated email from the ASF dual-hosted git repository.

tisonkun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git


The following commit(s) were added to refs/heads/master by this push:
     new ec8e9f4e fix: Undefined behavior (#548)
ec8e9f4e is described below

commit ec8e9f4e8e9d73f44f9072fad043849687988129
Author: Hyeonho Kim <pr...@apache.org>
AuthorDate: Thu Oct 15 00:01:36 2026 +0900

    fix: Undefined behavior (#548)
---
 .github/workflows/sanitize.yml       | 25 ++++++++++---------------
 common/include/memory_operations.hpp |  4 ++--
 2 files changed, 12 insertions(+), 17 deletions(-)

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;
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org