# HG changeset patch
# User Sebastien Jodogne <s.jodogne@gmail.com>
# Date 1612027151 -3600
# Node ID 0b2484663233d8f6b856563410f34fd22224f1f5
# Parent  cf44052fdf603c5d9fd119a9502abf636ee2ccf6
Fix build on big-endian architectures

diff -r cf44052fdf60 -r 0b2484663233 NEWS
--- 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)
 ==========================
diff -r cf44052fdf60 -r 0b2484663233 OrthancFramework/Sources/Compression/ZlibCompressor.cpp
--- 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]),