[Bf-blender-cvs] [9579643] alembic_basic_io: Fix crash dereferencing nullptr.

Kévin Dietrich noreply at git.blender.org
Sat Jul 23 18:15:41 CEST 2016


Commit: 95796438e1c8e11070f97cf16a6d699244f989b7
Author: Kévin Dietrich
Date:   Sat Jul 23 18:07:36 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB95796438e1c8e11070f97cf16a6d699244f989b7

Fix crash dereferencing nullptr.

===================================================================

M	source/blender/alembic/intern/abc_curves.cc

===================================================================

diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index 58752d7..39d494b 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -138,23 +138,25 @@ void AbcCurveWriter::do_write()
 			}
 		}
 
-		const size_t num_knots = KNOTSU(nurbs);
+		if (nurbs->knotsu != NULL) {
+			const size_t num_knots = KNOTSU(nurbs);
 
-		/* Add an extra knot at the beggining and end of the array since most apps
-		 * require/expect them. */
-		knots.resize(num_knots + 2);
+			/* Add an extra knot at the beggining and end of the array since most apps
+			 * require/expect them. */
+			knots.resize(num_knots + 2);
 
-		for (int i = 0; i < num_knots; ++i) {
-			knots[i + 1] = nurbs->knotsu[i];
-		}
+			for (int i = 0; i < num_knots; ++i) {
+				knots[i + 1] = nurbs->knotsu[i];
+			}
 
-		if ((nurbs->flagu & CU_NURB_CYCLIC) != 0) {
-			knots[0] = nurbs->knotsu[0];
-			knots[num_knots - 1] = nurbs->knotsu[num_knots - 1];
-		}
-		else {
-			knots[0] = (2.0f * nurbs->knotsu[0] - nurbs->knotsu[1]);
-			knots[num_knots - 1] = (2.0f * nurbs->knotsu[num_knots - 1] - nurbs->knotsu[num_knots - 2]);
+			if ((nurbs->flagu & CU_NURB_CYCLIC) != 0) {
+				knots[0] = nurbs->knotsu[0];
+				knots[num_knots - 1] = nurbs->knotsu[num_knots - 1];
+			}
+			else {
+				knots[0] = (2.0f * nurbs->knotsu[0] - nurbs->knotsu[1]);
+				knots[num_knots - 1] = (2.0f * nurbs->knotsu[num_knots - 1] - nurbs->knotsu[num_knots - 2]);
+			}
 		}
 
 		orders.push_back(nurbs->orderu + 1);




More information about the Bf-blender-cvs mailing list