[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
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

View File

@ -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() {

View File

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