[Dcmlib] Never trust the programer :)

Benoit Regrain benoit.regrain at creatis.insa-lyon.fr
Fri Oct 21 17:43:57 CEST 2005


Is the VM a real valid value to test ?
Is it really a good idea to do an assert on the VM ?
The user program will crash because a dicom file isn't correct...
I find this solution very bas :-(

And for the code... it's only a traduction of the previous code
using the new structures. But I don't know the writter of this previous
code. But it seems not wrong.

Benoit


----- Original Message ----- 
From: "Mathieu Malaterre" <mathieu.malaterre at kitware.com>
To: <dcmlib at creatis.insa-lyon.fr>
Sent: Friday, October 21, 2005 4:27 PM
Subject: [Dcmlib] Never trust the programer :)


> 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
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib



More information about the Dcmlib mailing list