# HG changeset patch # User Sebastien Jodogne # Date 1729096051 -7200 # Node ID 4b47151dea4cece23be8997260e6928995dc6ec2 # Parent 37e5d0918006a64d4743a3bc8fe17f14a5c507d2 fix crashes if handling very large images diff -r 37e5d0918006 -r 4b47151dea4c NEWS --- a/NEWS Mon Sep 30 10:22:12 2024 +0200 +++ b/NEWS Wed Oct 16 18:27:31 2024 +0200 @@ -29,6 +29,7 @@ * Fix C-Find queries not returning private tags in the modality worklist plugin. * Fix extremely rare error when 2 threads are trying to create the same folder in the File Storage at the same time. +* Fix crashes if handling very large images * Metrics: - fix a few metrics that were not published - added 2 metrics: orthanc_storage_cache_miss_count & orthanc_storage_cache_hit_count diff -r 37e5d0918006 -r 4b47151dea4c OrthancFramework/Sources/Images/ImageAccessor.cpp --- a/OrthancFramework/Sources/Images/ImageAccessor.cpp Mon Sep 30 10:22:12 2024 +0200 +++ b/OrthancFramework/Sources/Images/ImageAccessor.cpp Wed Oct 16 18:27:31 2024 +0200 @@ -139,7 +139,7 @@ return pitch_; } - unsigned int ImageAccessor::GetSize() const + size_t ImageAccessor::GetSize() const { return GetHeight() * GetPitch(); } @@ -165,7 +165,7 @@ { if (buffer_ != NULL) { - return buffer_ + y * pitch_; + return buffer_ + static_cast(y) * static_cast(pitch_); } else { @@ -184,7 +184,7 @@ if (buffer_ != NULL) { - return buffer_ + y * pitch_; + return buffer_ + static_cast(y) * static_cast(pitch_); } else { @@ -325,8 +325,8 @@ else { uint8_t* p = (buffer_ + - y * pitch_ + - x * GetBytesPerPixel()); + static_cast(y) * static_cast(pitch_) + + static_cast(x) * static_cast(GetBytesPerPixel())); if (readOnly_) { diff -r 37e5d0918006 -r 4b47151dea4c OrthancFramework/Sources/Images/ImageAccessor.h --- a/OrthancFramework/Sources/Images/ImageAccessor.h Mon Sep 30 10:22:12 2024 +0200 +++ b/OrthancFramework/Sources/Images/ImageAccessor.h Wed Oct 16 18:27:31 2024 +0200 @@ -86,7 +86,7 @@ unsigned int GetPitch() const; - unsigned int GetSize() const; + size_t GetSize() const; const void* GetConstBuffer() const; diff -r 37e5d0918006 -r 4b47151dea4c OrthancFramework/Sources/Images/ImageBuffer.cpp --- a/OrthancFramework/Sources/Images/ImageBuffer.cpp Mon Sep 30 10:22:12 2024 +0200 +++ b/OrthancFramework/Sources/Images/ImageBuffer.cpp Wed Oct 16 18:27:31 2024 +0200 @@ -47,7 +47,7 @@ */ pitch_ = GetBytesPerPixel() * width_; - size_t size = pitch_ * height_; + size_t size = static_cast(pitch_) * static_cast(height_); if (size == 0) {