[Dcmlib] Never trust the programer :)
Mathieu Malaterre
mathieu.malaterre at kitware.com
Fri Oct 21 16:27:16 CEST 2005
Benoit,
I just added an assert for kick and it is seg faulting. For instance:
DataEntry *entry = GetDataEntry(0x0020,0x0032);
if( !entry )
{
gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
entry = GetDataEntry(0x0020,0x0030);
if( !entry )
{
gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
return 0.0f;
}
}
if( entry->GetValueCount() == 3 )
{
gdcmAssertMacro( entry->IsValueCountValid() );
return (float)entry->GetValue(0);
}
return 0.0f;
so if 0x0020,0x0032 is not found, you check 0x0020,0x0030, which is then
found. But if it is found THEN you compare entry->GetValueCount()
against 3, but how do you know that VM is the same for 0020,0032 and
0020,0030 ?
Anyway this could have been safe, unfortunately 0020,0030 was entered as
VM=1 in the dict.
Question: Is this safe to let the programmer use GetValueCount ? Or
should we enforce IsValueCountValid ? Maybe an alternative would be to
run IsValueCountValid on the whole gdcmData just to see how respectful
the DICOM data are to 'our' dict...
Mathieu
More information about the Dcmlib
mailing list