Fix crash on Copy-Paste operation in GEOM module

This commit is contained in:
vsr 2010-09-16 08:45:08 +00:00
parent feaf2a6aac
commit 4c229dbd79

View File

@ -372,16 +372,13 @@ SALOMEDS::TMPFile* GEOM_Object_i::GetShapeStream()
BRepTools::Write(aShape, streamShape); BRepTools::Write(aShape, streamShape);
//Returns the number of bytes that have been stored in the stream's buffer. //Returns the number of bytes that have been stored in the stream's buffer.
int size = streamShape.str().size(); int size = streamShape.str().size();
char* buf = new char [size]; //Allocate octect buffer of required size
//Get pointer on internal character array in ostrstream CORBA::Octet* OctetBuf = SALOMEDS::TMPFile::allocbuf(size);
const char* valueOfStream = streamShape.str().c_str(); //Copy ostrstream content to the octect buffer
//Create copy of ostrstream content memcpy(OctetBuf, streamShape.str().c_str(), size);
memcpy(buf, valueOfStream, size); //Create and return TMPFile
CORBA::Octet* OctetBuf = (CORBA::Octet*)buf;
SALOMEDS::TMPFile_var SeqFile = new SALOMEDS::TMPFile(size,size,OctetBuf,1); SALOMEDS::TMPFile_var SeqFile = new SALOMEDS::TMPFile(size,size,OctetBuf,1);
return SeqFile._retn(); return SeqFile._retn();
} }