From: Joerg Riesmeier Date: Mon, 22 Apr 2024 10:11:11 +0000 (+0200) Subject: [PATCH] Fixed wrong error handling (previous commit). X-Git-Tag: archive/raspbian/3.6.8-6+rpi1^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=46f8efdd7cc6f358c829a1a55fb3c132f2ca65b0;p=dcmtk.git [PATCH] Fixed wrong error handling (previous commit). Fixed wrong error handling introduced with the previous commit. Gbp-Pq: Name 0003-Fixed-wrong-error-handling-previous-commit.patch --- diff --git a/dcmrt/libsrc/drttypes.cc b/dcmrt/libsrc/drttypes.cc index 77ff1674..097ab972 100644 --- a/dcmrt/libsrc/drttypes.cc +++ b/dcmrt/libsrc/drttypes.cc @@ -210,11 +210,11 @@ OFCondition DRTTypes::getAndCheckStringValueFromDataset(DcmItem &dataset, { DcmStack stack; OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); - if (result.good() && stack.top()->isElement()) + if (result.good()) { - DcmElement *element = OFstatic_cast(DcmElement *, stack.top()); - if (element != NULL) + if (stack.top()->isElement()) { + DcmElement *element = OFstatic_cast(DcmElement *, stack.top()); if (checkElementValue(*element, vm, type, result, moduleName)) result = element->getOFString(stringValue, 0); else diff --git a/dcmsr/libsrc/dsrtypes.cc b/dcmsr/libsrc/dsrtypes.cc index a9d62185..166bfabf 100644 --- a/dcmsr/libsrc/dsrtypes.cc +++ b/dcmsr/libsrc/dsrtypes.cc @@ -1178,13 +1178,17 @@ OFCondition DSRTypes::getAndCheckElementFromDataset(DcmItem &dataset, DcmStack stack; const DcmTagKey tagKey = delem.getTag(); OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); - if (result.good() && stack.top()->isElement()) + if (result.good()) { - /* copy object from search stack */ - result = delem.copyFrom(*stack.top()); - /* we need a reference to the original element in order to determine the SpecificCharacterSet */ - if (!checkElementValue(OFstatic_cast(DcmElement *, stack.top()), tagKey, vm, type, result, moduleName, acceptViolation)) - result = SR_EC_InvalidValue; + if (stack.top()->isElement()) + { + /* copy object from search stack */ + result = delem.copyFrom(*stack.top()); + /* we need a reference to the original element in order to determine the SpecificCharacterSet */ + if (!checkElementValue(OFstatic_cast(DcmElement *, stack.top()), tagKey, vm, type, result, moduleName, acceptViolation)) + result = SR_EC_InvalidValue; + } else + result = EC_CorruptedData; } /* the element could not be found in the dataset */ else if (!checkElementValue(delem, vm, type, result, moduleName, acceptViolation)) @@ -1203,13 +1207,17 @@ OFCondition DSRTypes::getAndCheckStringValueFromDataset(DcmItem &dataset, { DcmStack stack; OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); - if (result.good() && stack.top()->isElement()) + if (result.good()) { - DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); - /* we need a reference to the original element in order to determine the SpecificCharacterSet */ - if (!checkElementValue(delem, tagKey, vm, type, result, moduleName, acceptViolation)) - result = SR_EC_InvalidValue; - delem->getOFString(stringValue, 0); + if (stack.top()->isElement()) + { + DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); + /* we need a reference to the original element in order to determine the SpecificCharacterSet */ + if (!checkElementValue(delem, tagKey, vm, type, result, moduleName, acceptViolation)) + result = SR_EC_InvalidValue; + delem->getOFString(stringValue, 0); + } else + result = EC_CorruptedData; } else { if ((type == "1") || (type == "2")) {