From: vsr Date: Fri, 9 Dec 2005 15:43:44 +0000 (+0000) Subject: Bug PAL10850: A problem in SALOMEDS_Tool::PutStreamToFiles() method : crash X-Git-Tag: T_3_1_0pre~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e09e425f145c601c4270f2eb70e3c298a1fd5575;p=modules%2Fkernel.git Bug PAL10850: A problem in SALOMEDS_Tool::PutStreamToFiles() method : crash --- 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