# HG changeset patch # User Sebastien Jodogne # Date 1648032548 -3600 # Node ID 94edc2c897684c4729fe7021d292e91c137fa4b9 # Parent e1495a34cd392653309fff4ab568948ebe5fe83c# Parent 964bbf5cb365ba2cfbb730af62a00a2d082d6957 integration mainline->more-tags diff -r e1495a34cd39 -r 94edc2c89768 OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp --- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Tue Mar 22 19:11:56 2022 +0100 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Wed Mar 23 11:49:08 2022 +0100 @@ -1962,8 +1962,8 @@ Uint16 rows, columns, bitsAllocated, bitPosition; const Sint16* origin = NULL; unsigned long originSize = 0; - const Uint8* overlayData = NULL; - unsigned long overlaySize = 0; + DcmElement* overlayElement = NULL; + Uint8* overlayData = NULL; if (dataset.findAndGetUint16(DcmTagKey(group, 0x0010), rows).good() && dataset.findAndGetUint16(DcmTagKey(group, 0x0011), columns).good() && @@ -1974,11 +1974,25 @@ bitsAllocated == 1 && dataset.findAndGetUint16(DcmTagKey(group, 0x0102), bitPosition).good() && bitPosition == 0 && - dataset.findAndGetUint8Array(DcmTagKey(group, 0x3000), overlayData, &overlaySize).good() && + dataset.findAndGetElement(DcmTagKey(group, 0x3000), overlayElement).good() && + overlayElement != NULL && + overlayElement->getUint8Array(overlayData).good() && overlayData != NULL) { + /** + * WARNING - It might seem easier to use + * "dataset.findAndGetUint8Array()" that directly gives the size + * of the overlay data (using the "count" parameter), instead of + * "dataset.findAndGetElement()". Unfortunately, this does *not* + * work with Emscripten/WebAssembly, that reports a "count" that + * is half the number of bytes, presumably because of + * discrepancies in the way sizeof are computed inside DCMTK. + * The method "getLengthField()" reports the correct number of + * bytes, even if targeting WebAssembly. + **/ + unsigned int expectedSize = Ceiling(rows * columns, 8); - if (overlaySize < expectedSize) + if (overlayElement->getLengthField() < expectedSize) { throw OrthancException(ErrorCode_CorruptedFile, "Overlay doesn't have a valid number of bits"); } diff -r e1495a34cd39 -r 94edc2c89768 OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Tue Mar 22 19:11:56 2022 +0100 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Mar 23 11:49:08 2022 +0100 @@ -95,7 +95,7 @@ std::vector items_; public: - PathHelper(const std::vector& path) + explicit PathHelper(const std::vector& path) { items_.resize(path.size()); for (size_t i = 0; i < path.size(); i++)