0022232: [CEA 837] Memory corruption in GEOM/SMESH that leads to segfault on debian64

Fix "Mismatched free() / delete / delete []" valgrind error

-  Standard_EXPORT char* GetName();
+  Standard_EXPORT TCollection_AsciiString GetName();
This commit is contained in:
eap 2013-06-19 14:23:50 +00:00
parent e69511781d
commit 1d2e9cb443
2 changed files with 6 additions and 6 deletions

View File

@ -314,16 +314,16 @@ void GEOM_Object::SetName(const char* theName)
* GetName
*/
//=============================================================================
char* GEOM_Object::GetName()
TCollection_AsciiString GEOM_Object::GetName()
{
TCollection_AsciiString aName;
Handle(TDataStd_Name) aNameAttr;
if(!_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) return NULL;
TCollection_AsciiString aName(aNameAttr->Get());
if(_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr))
aName = aNameAttr->Get();
// do not return pointer of local variable
// return aName.ToCString();
// the following code could lead to memory leak, so take care about recieved pointer
return strdup(aName.ToCString());
return aName;
}
//=============================================================================

View File

@ -213,7 +213,7 @@ class GEOM_Object : public MMgt_TShared
Standard_EXPORT void SetName(const char* theName);
//Returns a name of this GEOM_Object
Standard_EXPORT char* GetName();
Standard_EXPORT TCollection_AsciiString GetName();
//Sets a color of this GEOM_Object
Standard_EXPORT void SetColor(const Color& theColor);