changeset 4492:0b2484663233

Fix build on big-endian architectures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 30 Jan 2021 18:19:11 +0100
parents cf44052fdf60
children b57ca702a430
files NEWS OrthancFramework/Sources/Compression/ZlibCompressor.cpp
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Jan 29 11:51:42 2021 +0100
+++ b/NEWS	Sat Jan 30 18:19:11 2021 +0100
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* Fix build on big-endian architectures
+
 
 Version 1.9.0 (2021-01-29)
 ==========================
--- a/OrthancFramework/Sources/Compression/ZlibCompressor.cpp	Fri Jan 29 11:51:42 2021 +0100
+++ b/OrthancFramework/Sources/Compression/ZlibCompressor.cpp	Sat Jan 30 18:19:11 2021 +0100
@@ -123,6 +123,9 @@
 
     uint64_t uncompressedSize = ReadUncompressedSizePrefix(compressed, compressedSize);
     
+    // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix
+    uncompressedSize = le64toh(uncompressedSize);
+
     try
     {
       uncompressed.resize(static_cast<size_t>(uncompressedSize));
@@ -132,9 +135,6 @@
       throw OrthancException(ErrorCode_NotEnoughMemory);
     }
 
-    // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix
-    uncompressedSize = le64toh(uncompressedSize);
-
     uLongf tmp = static_cast<uLongf>(uncompressedSize);
     int error = uncompress
       (reinterpret_cast<uint8_t*>(&uncompressed[0]),