[cpp] Fix SkeletonBinary::readLong() UB, revert bendDirection fix again ...

This commit is contained in:
Mario Zechner 2025-07-26 01:18:34 +02:00
parent 691f55a315
commit 9b778bc508
3 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,7 @@ source ../formatters/logging/logging.sh
# Parse arguments # Parse arguments
BUILD_TYPE="debug" BUILD_TYPE="debug"
NOFILEIO="" NOFILEIO=""
SANITIZE=""
CLEAN="" CLEAN=""
for arg in "$@"; do for arg in "$@"; do
@ -25,9 +26,12 @@ for arg in "$@"; do
nofileio) nofileio)
NOFILEIO="-DSPINE_NO_FILE_IO=ON" NOFILEIO="-DSPINE_NO_FILE_IO=ON"
;; ;;
sanitize)
SANITIZE="-DSPINE_SANITIZE=ON"
;;
*) *)
log_fail "Unknown argument: $arg" log_fail "Unknown argument: $arg"
log_detail "Usage: $0 [clean] [release|debug] [nofileio]" log_detail "Usage: $0 [clean] [release|debug] [nofileio] [sanitize]"
exit 1 exit 1
;; ;;
esac esac
@ -44,7 +48,7 @@ fi
# Configure and build # Configure and build
log_action "Configuring $BUILD_TYPE 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 log_ok
else else
log_fail log_fail

View File

@ -171,10 +171,10 @@ namespace spine {
} }
inline long long readLong() { inline long long readLong() {
long long result = (unsigned long long) readInt(); unsigned long long result = (unsigned long long) readInt();
result <<= 32; result <<= 32;
result |= (unsigned long long) readInt(); result |= (unsigned long long) readInt();
return result; return (long long) result;
} }
inline float readFloat() { inline float readFloat() {

View File

@ -236,7 +236,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
data->_skinRequired = (flags & 1) != 0; data->_skinRequired = (flags & 1) != 0;
data->_uniform = (flags & 2) != 0; data->_uniform = (flags & 2) != 0;
IkConstraintPose &setup = data->_setup; IkConstraintPose &setup = data->_setup;
setup._bendDirection = (flags & 4) != 0 ? -1 : 1; setup._bendDirection = (flags & 4) != 0 ? 1 : -1;
setup._compress = (flags & 8) != 0; setup._compress = (flags & 8) != 0;
setup._stretch = (flags & 16) != 0; setup._stretch = (flags & 16) != 0;
if ((flags & 32) != 0) setup._mix = (flags & 64) != 0 ? input.readFloat() : 1; if ((flags & 32) != 0) setup._mix = (flags & 64) != 0 ? input.readFloat() : 1;