From 9b778bc508a5572bd5706cf7fdb2ed63ed1586bf Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sat, 26 Jul 2025 01:18:34 +0200 Subject: [PATCH] [cpp] Fix SkeletonBinary::readLong() UB, revert bendDirection fix again ... --- spine-cpp/build.sh | 8 ++++++-- spine-cpp/include/spine/SkeletonBinary.h | 4 ++-- spine-cpp/src/spine/SkeletonBinary.cpp | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spine-cpp/build.sh b/spine-cpp/build.sh index 53f7b352d..4e2069c3e 100755 --- a/spine-cpp/build.sh +++ b/spine-cpp/build.sh @@ -9,6 +9,7 @@ source ../formatters/logging/logging.sh # Parse arguments BUILD_TYPE="debug" NOFILEIO="" +SANITIZE="" CLEAN="" for arg in "$@"; do @@ -25,9 +26,12 @@ for arg in "$@"; do nofileio) NOFILEIO="-DSPINE_NO_FILE_IO=ON" ;; + sanitize) + SANITIZE="-DSPINE_SANITIZE=ON" + ;; *) log_fail "Unknown argument: $arg" - log_detail "Usage: $0 [clean] [release|debug] [nofileio]" + log_detail "Usage: $0 [clean] [release|debug] [nofileio] [sanitize]" exit 1 ;; esac @@ -44,7 +48,7 @@ fi # Configure and build log_action "Configuring $BUILD_TYPE build" -if CMAKE_OUTPUT=$(cmake --preset=$BUILD_TYPE $NOFILEIO . 2>&1); then +if CMAKE_OUTPUT=$(cmake --preset=$BUILD_TYPE $NOFILEIO $SANITIZE . 2>&1); then log_ok else log_fail diff --git a/spine-cpp/include/spine/SkeletonBinary.h b/spine-cpp/include/spine/SkeletonBinary.h index 027835d56..a6179744f 100644 --- a/spine-cpp/include/spine/SkeletonBinary.h +++ b/spine-cpp/include/spine/SkeletonBinary.h @@ -171,10 +171,10 @@ namespace spine { } inline long long readLong() { - long long result = (unsigned long long) readInt(); + unsigned long long result = (unsigned long long) readInt(); result <<= 32; result |= (unsigned long long) readInt(); - return result; + return (long long) result; } inline float readFloat() { diff --git a/spine-cpp/src/spine/SkeletonBinary.cpp b/spine-cpp/src/spine/SkeletonBinary.cpp index 1b3f6007a..a0de8d6eb 100644 --- a/spine-cpp/src/spine/SkeletonBinary.cpp +++ b/spine-cpp/src/spine/SkeletonBinary.cpp @@ -236,7 +236,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons data->_skinRequired = (flags & 1) != 0; data->_uniform = (flags & 2) != 0; IkConstraintPose &setup = data->_setup; - setup._bendDirection = (flags & 4) != 0 ? -1 : 1; + setup._bendDirection = (flags & 4) != 0 ? 1 : -1; setup._compress = (flags & 8) != 0; setup._stretch = (flags & 16) != 0; if ((flags & 32) != 0) setup._mix = (flags & 64) != 0 ? input.readFloat() : 1;