From b2a4aab9e4bdff9e5c5828186472c4993e2cda0d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 25 Nov 2015 20:31:20 +0100 Subject: [PATCH] Fix T46848: more OpenNL crashes due to uninitialized variables. --- intern/opennl/intern/opennl.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/intern/opennl/intern/opennl.cpp b/intern/opennl/intern/opennl.cpp index 446a1a38f0d..331291e790a 100644 --- a/intern/opennl/intern/opennl.cpp +++ b/intern/opennl/intern/opennl.cpp @@ -57,17 +57,28 @@ typedef Eigen::Triplet EigenTriplet; /* NLContext data structure */ -typedef struct { +struct NLCoeff { + NLCoeff() + { + index = 0; + value = 0.0; + } NLuint index; NLdouble value; -} NLCoeff; +}; -typedef struct { +struct NLVariable { + NLVariable() + { + memset(value, 0, sizeof(value)); + locked = false; + index = 0; + } NLdouble value[4]; NLboolean locked; NLuint index; std::vector a; -} NLVariable; +}; #define NL_STATE_INITIAL 0 #define NL_STATE_SYSTEM 1 @@ -340,7 +351,9 @@ void nlMatrixAdd(NLContext *context, NLuint row, NLuint col, NLdouble value) if(!context->least_squares) row = context->variable[row].index; - NLCoeff coeff = {row, value}; + NLCoeff coeff; + coeff.index = row; + coeff.value = value; context->variable[col].a.push_back(coeff); } else {