changeset 6804:4b8794c12e31

fix MemoryStorageArea::ReadRange()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 18 May 2026 20:56:08 +0200
parents b28524cf93a9
children 91cb6f565e7d
files OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp	Mon May 18 20:25:02 2026 +0200
+++ b/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp	Mon May 18 20:56:08 2026 +0200
@@ -94,7 +94,7 @@
       const uint64_t size = end - start;
       if (static_cast<uint64_t>(static_cast<size_t>(size)) != size)
       {
-        throw OrthancException(ErrorCode_InternalError, "Buffer larger than 4GB, which is too large for Orthanc running in 32bits");
+        throw OrthancException(ErrorCode_NotEnoughMemory, "Buffer larger than 4GB, which is too large for Orthanc running in 32bits");
       }
 
       Mutex::ScopedLock lock(mutex_);
@@ -116,11 +116,9 @@
       else
       {
         std::string range;
-        range.resize(static_cast<size_t>(size));
-        assert(!range.empty());
+        assert(size != 0);
+        range.assign(found->second->c_str() + start, size);
 
-        memcpy(&range[0], &found->second[start], range.size()); // NOLINT(bugprone-undefined-memory-manipulation)
-        
         return StringMemoryBuffer::CreateFromSwap(range);
       }
     }