Use "SUComponentInstanceSaveAs" get a error

Hello:
I use this:

SUEntitiesRef entities = SU_INVALID;
SUModelGetEntities(model, &entities);


SUGeometryInputRef input = SU_INVALID;
SUGeometryInputCreate(&input);

SUPoint3D vertices[4] = { { 10,   10,   10 },
						{ 100, 100, 10 },
						{ 100, 100, 100 },
						{ 10,  10,   100 } };
SUGeometryInputSetVertices(input, 4, vertices);

// Add the first face
SULoopInputRef loop = SU_INVALID;
SULoopInputCreate(&loop);
SULoopInputAddVertexIndex(loop, 0);
SULoopInputAddVertexIndex(loop, 1);
SULoopInputAddVertexIndex(loop, 2);
SULoopInputAddVertexIndex(loop, 3);
size_t face_index;
SUGeometryInputAddFace(input, &loop, &face_index);


SUComponentDefinitionRef comp_def = SU_INVALID;
SUComponentDefinitionCreate(&comp_def);
SUComponentDefinitionSetName(comp_def, "CS");
SUModelAddComponentDefinitions(model, 1, &comp_def);
SUEntitiesRef comp_def_entities = SU_INVALID;
SUComponentDefinitionGetEntities(comp_def, &comp_def_entities);

SUEntitiesFill(comp_def_entities, input, true);
// Clean up geom_input
SUGeometryInputRelease(&input);

SUComponentInstanceRef instance = SU_INVALID;
SUComponentDefinitionCreateInstance(comp_def, &instance);
SUEntitiesAddInstance(entities, instance, NULL);
SUComponentInstanceSaveAs(instance, "comp.skp");
SUModelSaveToFile(model, "new_model.skp");

When I open the “comp.skp”, it has an error report,however,the “new_model.skp” is well.
the error :
The persistence ID of the primitive CEdge (25) is out of range - fixed

The persistence ID of the primitive CVertex (26) is out of range - fixed

The persistence ID of the primitive CVertex (27) is out of range - fixed

The persistence ID of the primitive CEdge (28) is out of range - fixed

The persistence ID of the primitive CVertex (29) is out of range - fixed

The persistence ID of the primitive CEdge (30) is out of range - fixed

The persistence ID of the primitive CVertex (31) is out of range - fixed

The persistence ID of the primitive CEdge (32) is out of range - fixed

The persistence ID of the primitive CFace (33) is out of range - fixed

Where is wrong?

This function has serious issues:

Before diving deeper - can you check the return values of each SU function call? Your example doesn’t do that and will just continue even in the face of errors. Stop at the first function that gives you an error and trace back the data you are passing around.