From e09e425f145c601c4270f2eb70e3c298a1fd5575 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 9 Dec 2005 15:43:44 +0000 Subject: [PATCH] Bug PAL10850: A problem in SALOMEDS_Tool::PutStreamToFiles() method : crash --- src/TOOLSDS/SALOMEDS_Tool.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/TOOLSDS/SALOMEDS_Tool.cxx b/src/TOOLSDS/SALOMEDS_Tool.cxx index d36e87405..fa13a1eb4 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.cxx +++ b/src/TOOLSDS/SALOMEDS_Tool.cxx @@ -267,15 +267,18 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, const std::string& theToDirectory, const int theNamesOnly) { - if(theStream.length() == 0) - return NULL; + SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames; + + if(theStream.length() == 0) + return aFiles; //Get a temporary directory for saving a file TCollection_AsciiString aTmpDir(const_cast(theToDirectory.c_str())); unsigned char *aBuffer = (unsigned char*)theStream.NP_data(); - if(aBuffer == NULL) return NULL; + if(aBuffer == NULL) + return aFiles; long aFileSize, aCurrentPos = 4; int i, aFileNameSize, aNbFiles = 0; @@ -283,7 +286,6 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, //Copy the number of files in the stream memcpy(&aNbFiles, aBuffer, sizeof(int)); - SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames; aFiles->length(aNbFiles); for(i=0; i