# HG changeset patch # User Alain Mazy # Date 1776176782 -7200 # Node ID 3bd8715e21bcd41ed1f153dfce3ef0cb1f529d64 # Parent 92fc8268cff13b2eb52eb145805a5e80f5a26fa7 Fix ImageAccessor: GetBytesPerPixel uses format_ that is not initialized at this point diff -r 92fc8268cff1 -r 3bd8715e21bc OrthancFramework/Sources/Images/ImageAccessor.cpp --- a/OrthancFramework/Sources/Images/ImageAccessor.cpp Tue Apr 14 13:44:43 2026 +0200 +++ b/OrthancFramework/Sources/Images/ImageAccessor.cpp Tue Apr 14 16:26:22 2026 +0200 @@ -224,6 +224,13 @@ unsigned int pitch, const void *buffer) { + readOnly_ = true; + format_ = format; + width_ = width; + height_ = height; + pitch_ = pitch; + buffer_ = reinterpret_cast(const_cast(buffer)); + const uint64_t size = static_cast(height) * static_cast(pitch); if (static_cast(GetBytesPerPixel() * width) > static_cast(pitch) || @@ -231,13 +238,6 @@ { throw OrthancException(ErrorCode_ParameterOutOfRange); } - - readOnly_ = true; - format_ = format; - width_ = width; - height_ = height; - pitch_ = pitch; - buffer_ = reinterpret_cast(const_cast(buffer)); } void ImageAccessor::GetReadOnlyAccessor(ImageAccessor &target) const @@ -252,6 +252,13 @@ unsigned int pitch, void *buffer) { + readOnly_ = false; + format_ = format; + width_ = width; + height_ = height; + pitch_ = pitch; + buffer_ = reinterpret_cast(buffer); + const uint64_t size = static_cast(height) * static_cast(pitch); if (static_cast(GetBytesPerPixel() * width) > static_cast(pitch) || @@ -259,13 +266,6 @@ { throw OrthancException(ErrorCode_ParameterOutOfRange); } - - readOnly_ = false; - format_ = format; - width_ = width; - height_ = height; - pitch_ = pitch; - buffer_ = reinterpret_cast(buffer); }