changeset 4528:93a51d228d80

fix segmentation fault during anonymization on big-endian architectures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Feb 2021 15:07:54 +0100
parents 31f940334496
children 5774fe497ff2
files OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Wed Feb 24 12:39:35 2021 +0100
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Wed Feb 24 15:07:54 2021 +0100
@@ -2299,7 +2299,8 @@
       Uint16* data16 = NULL;
       Uint8* data = NULL;
 
-      if (evr == EVR_OW &&
+      if ((element.getTag() == DCM_PixelData ||  // (*) New in Orthanc 1.9.1
+           evr == EVR_OW) &&
           element.getUint16Array(data16) == EC_Normal)
       {
         visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data16, element.getLength());
@@ -2307,6 +2308,14 @@
       else if (evr != EVR_OW &&
                element.getUint8Array(data) == EC_Normal)
       {
+        /**
+         * WARNING: The call to "getUint8Array()" crashes
+         * (segmentation fault) on big-endian architectures if applied
+         * to pixel data, during the call to "swapIfNecessary()" in
+         * "DcmPolymorphOBOW::getUint8Array()" (this method is not
+         * reimplemented in derived class "DcmPixelData"). However,
+         * "getUint16Array()" works correctly, hence (*).
+         **/
         visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data, element.getLength());
       }
       else