Skip to content

Commit

Permalink
Check for nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur Rauf Bingol committed Apr 21, 2019
1 parent 7ac0d44 commit 9bc1f9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/json2on/json2on.cpp
Expand Up @@ -52,13 +52,15 @@ bool json2on(std::string &jsonString, Config &cfg, std::string &fileName)
{
ON_NurbsCurve *geom;
constructCurveData(d, cfg, geom);
model.AddManagedModelGeometryComponent(geom, nullptr);
if (geom != nullptr)
model.AddManagedModelGeometryComponent(geom, nullptr);
}
if (root["shape"]["type"].asString() == "surface")
{
ON_Brep *geom;
constructSurfaceData(d, cfg, geom);
model.AddManagedModelGeometryComponent(geom, nullptr);
if (geom != nullptr)
model.AddManagedModelGeometryComponent(geom, nullptr);
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/rw3dm/rw3dm.cpp
Expand Up @@ -414,8 +414,15 @@ void constructSurfaceData(Json::Value &data, Config &cfg, ON_Brep *&brep)
// Each surface (and the trim curves) should belong to a BRep object
brep = ON_Brep::New();

// Add surface to the BRep object
brep->Create(nurbsSurface);
// Create a BRep object from the NURBS surface
if (!brep->Create(nurbsSurface))
{
delete nurbsSurface;
delete brep;
nurbsSurface = nullptr;
brep = nullptr;
return;
}

// Process trims
if (data.isMember("trims"))
Expand Down

0 comments on commit 9bc1f9e

Please sign in to comment.