From 80fc4809a35964d96c9b1e824db42288dc406a27 Mon Sep 17 00:00:00 2001 From: jpr Date: Thu, 10 Feb 2005 09:07:19 +0000 Subject: [PATCH] Duplicate Matthieu's hack to prevent bombing in Anonymize --- src/gdcmFile.cxx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index f0fbb0cd..1df0a70c 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/02/09 22:11:09 $ - Version: $Revision: 1.218 $ + Date: $Date: 2005/02/10 09:07:19 $ + Version: $Revision: 1.219 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1159,6 +1159,7 @@ void File::AnonymizeNoLoad() { std::fstream *fp = new std::fstream(Filename.c_str(), std::ios::in | std::ios::out | std::ios::binary); + // TODO : FIXME // how to white out disk space if longer than 50 ? char spaces[50] = " "; @@ -1170,18 +1171,22 @@ void File::AnonymizeNoLoad() for (ListElements::iterator it = AnonymizeList.begin(); it != AnonymizeList.end(); ++it) - { - d = GetDocEntry( (*it).Group, (*it).Elem); + { + d = GetDocEntry( (*it).Group, (*it).Elem); + + if ( d == NULL) + continue; if ( dynamic_cast(d) || dynamic_cast(d) ) continue; if( d == NULL) - { - gdcmWarningMacro( "I have no idea why this is NULL but this solve the seg fault"); + { + gdcmWarningMacro( "I have no idea why this is NULL " + << "but this solves the seg fault"); continue; - } + } offset = d->GetOffset(); lgth = d->GetLength(); fp->seekp( offset, std::ios::beg ); @@ -1243,10 +1248,19 @@ bool File::AnonymizeFile() { d = GetDocEntry( (*it).Group, (*it).Elem); + if ( d == NULL) + continue; + if ( dynamic_cast(d) || dynamic_cast(d) ) continue; + if( d == NULL) + { + gdcmWarningMacro( "I have no idea why this is NULL " + << "but this solves the seg fault"); + continue; + } SetValEntry ((*it).Value, (*it).Group, (*it).Elem); } } -- 2.45.1