Mercurial > hg > orthanc
changeset 6720:3bd8715e21bc
Fix ImageAccessor: GetBytesPerPixel uses format_ that is not initialized at this point
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 14 Apr 2026 16:26:22 +0200 |
| parents | 92fc8268cff1 |
| children | 7135711cd564 |
| files | OrthancFramework/Sources/Images/ImageAccessor.cpp |
| diffstat | 1 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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<uint8_t*>(const_cast<void*>(buffer)); + const uint64_t size = static_cast<uint64_t>(height) * static_cast<uint64_t>(pitch); if (static_cast<uint64_t>(GetBytesPerPixel() * width) > static_cast<uint64_t>(pitch) || @@ -231,13 +238,6 @@ { throw OrthancException(ErrorCode_ParameterOutOfRange); } - - readOnly_ = true; - format_ = format; - width_ = width; - height_ = height; - pitch_ = pitch; - buffer_ = reinterpret_cast<uint8_t*>(const_cast<void*>(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<uint8_t*>(buffer); + const uint64_t size = static_cast<uint64_t>(height) * static_cast<uint64_t>(pitch); if (static_cast<uint64_t>(GetBytesPerPixel() * width) > static_cast<uint64_t>(pitch) || @@ -259,13 +266,6 @@ { throw OrthancException(ErrorCode_ParameterOutOfRange); } - - readOnly_ = false; - format_ = format; - width_ = width; - height_ = height; - pitch_ = pitch; - buffer_ = reinterpret_cast<uint8_t*>(buffer); }
