comparison OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 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 72af097bb92b
comparison
equal deleted inserted replaced
4527:31f940334496 4528:93a51d228d80
2297 evr == EVR_UN) // unknown value representation 2297 evr == EVR_UN) // unknown value representation
2298 { 2298 {
2299 Uint16* data16 = NULL; 2299 Uint16* data16 = NULL;
2300 Uint8* data = NULL; 2300 Uint8* data = NULL;
2301 2301
2302 if (evr == EVR_OW && 2302 if ((element.getTag() == DCM_PixelData || // (*) New in Orthanc 1.9.1
2303 evr == EVR_OW) &&
2303 element.getUint16Array(data16) == EC_Normal) 2304 element.getUint16Array(data16) == EC_Normal)
2304 { 2305 {
2305 visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data16, element.getLength()); 2306 visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data16, element.getLength());
2306 } 2307 }
2307 else if (evr != EVR_OW && 2308 else if (evr != EVR_OW &&
2308 element.getUint8Array(data) == EC_Normal) 2309 element.getUint8Array(data) == EC_Normal)
2309 { 2310 {
2311 /**
2312 * WARNING: The call to "getUint8Array()" crashes
2313 * (segmentation fault) on big-endian architectures if applied
2314 * to pixel data, during the call to "swapIfNecessary()" in
2315 * "DcmPolymorphOBOW::getUint8Array()" (this method is not
2316 * reimplemented in derived class "DcmPixelData"). However,
2317 * "getUint16Array()" works correctly, hence (*).
2318 **/
2310 visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data, element.getLength()); 2319 visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data, element.getLength());
2311 } 2320 }
2312 else 2321 else
2313 { 2322 {
2314 visitor.VisitNotSupported(parentTags, parentIndexes, tag, vr); 2323 visitor.VisitNotSupported(parentTags, parentIndexes, tag, vr);