I've recently encountered DCMTK behavior that looks like a bug to me, and I can't find similar threads or existing tickets.
Scenario:
* Start with any valid DICOM data set
* Add element 0020, 0032 - Image Position (VR: Decimal string, VM - 3). For example set it to "-1\-2\-3" (padding is ommited)
* Try to replace only middle value - either by calling putOFStringAtPos("2", 1) or via similar call to the putFloat64
Expected result: value is changed to the "-1\2\-3"
actual: value is "1\2-3"
Note: similar issue happens with other tags, like 0020,0037 for the intermediate positions
Looking at the sources of DCMTK, I think the problem is in the
Code: Select all
OFCondition DcmByteString::putOFStringAtPos
in the very end, it contains:
Code: Select all
else
{
str = str.replace(leftPos+1, rightPos - leftPos, stringVal);
}
but the second parameter should be rightPos - leftPos - 1, otherwise it overwrites characted at the rightPos, which is the next backslash.