Permalink
Browse files

Fixed more potential runtime crashes

  • Loading branch information...
1 parent a4cad15 commit 5bb4ed1d7d4840012e641bbd7838565dfefcba26 @jzrake committed Apr 25, 2012
Showing with 13 additions and 7 deletions.
  1. +13 −7 src/luview.cpp
View
@@ -682,6 +682,9 @@ class FunctionMapping : public DataSource
if (input == NULL) {
luaL_error(__lua_state, "broken pipeline: missing data source");
}
+ if (transform == NULL) {
+ luaL_error(__lua_state, "broken pipeline: missing transform");
+ }
int Nd_domain = input->get_num_components();
int Nd_range = this->get_num_components();
@@ -750,18 +753,21 @@ class SurfaceNURBS : public DrawableObject
}
GLfloat *surfdata = cp->second->get_data();
- GLfloat *colrdata = cm->second->get_data();
+ GLfloat *colordata = NULL;
if (cp->second->get_num_components() != 3) {
luaL_error(__lua_state,
"data source 'control_points' must provide 3 components "
"(x,y,z)");
return;
}
- if (cm->second->get_num_components() != 4) {
- luaL_error(__lua_state,
- "data source 'colors' must provide 4 components (r,g,b,a)");
- return;
+ if (cm != DataSources.end()) {
+ colordata = cm->second->get_data();
+ if (cm->second->get_num_components() != 4) {
+ luaL_error(__lua_state,
+ "data source 'colors' must provide 4 components (r,g,b,a)");
+ return;
+ }
}
int Nu = cp->second->get_num_points(0);
@@ -791,10 +797,10 @@ class SurfaceNURBS : public DrawableObject
3*su, 3*sv, surfdata,
order, order, GL_MAP2_VERTEX_3);
- if (cm != DataSources.end()) {
+ if (colordata) {
gluNurbsSurface(theNurb,
Nu + order, knots_u, Nv + order, knots_v,
- 4*su, 4*sv, cm->second->get_data(),
+ 4*su, 4*sv, colordata,
order, order, GL_MAP2_COLOR_4);
}

0 comments on commit 5bb4ed1

Please sign in to comment.