From: vsr Date: Thu, 16 Sep 2010 08:45:08 +0000 (+0000) Subject: Fix crash on Copy-Paste operation in GEOM module X-Git-Tag: V5_1_5a1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4c229dbd797c7866b66f2f915e73c713c1feaee0;p=modules%2Fgeom.git Fix crash on Copy-Paste operation in GEOM module --- diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index 6b9d7ea00..0adae0632 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -372,16 +372,13 @@ SALOMEDS::TMPFile* GEOM_Object_i::GetShapeStream() BRepTools::Write(aShape, streamShape); //Returns the number of bytes that have been stored in the stream's buffer. int size = streamShape.str().size(); - char* buf = new char [size]; - //Get pointer on internal character array in ostrstream - const char* valueOfStream = streamShape.str().c_str(); - //Create copy of ostrstream content - memcpy(buf, valueOfStream, size); - - CORBA::Octet* OctetBuf = (CORBA::Octet*)buf; + //Allocate octect buffer of required size + CORBA::Octet* OctetBuf = SALOMEDS::TMPFile::allocbuf(size); + //Copy ostrstream content to the octect buffer + memcpy(OctetBuf, streamShape.str().c_str(), size); + //Create and return TMPFile SALOMEDS::TMPFile_var SeqFile = new SALOMEDS::TMPFile(size,size,OctetBuf,1); return SeqFile._retn(); - }