Skip to content

Possible attribute assignmnent bug for ENTITY_TYPE in STEPattribute.cc #328

@pcjc2

Description

@pcjc2

Found a bug when running the example CPP code under valgrind..

Not sure of the correct fix, but I'm fairly sure we should not delete the ptr.c when assigning a new Entity to the attribute. Something more in keeping with the neighbouring definitions?

@@ -961,10 +962,9 @@ void STEPattribute::Binary( SDAI_Binary * bin ) {

 void STEPattribute::Entity( SDAI_Application_instance * ent ) {
     assert( NonRefType() == ENTITY_TYPE );
-    if( ptr.c ) {
-        delete ptr.c;
+    if( ptr.c == NULL ) {
+        ptr.c = new (SDAI_Application_instance * );
     }
-    ptr.c = new (SDAI_Application_instance * );
     *( ptr.c ) = ent;
 }

I think, given that the early bound schema create their attribute definitions to point to data within the C++ classes, it is important not to detach this association when setting attributes via the late bound APIs such as this one.

FWIW, I'm very new to STEPCODE, (and not a regular C++ developer), so please scrutinise the issue, don't take my above patch as correct... it may not be! (But it keeps Valgrind a lot happier for the shipped example code).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions