From 5f40773fac6fe1c11bed2bed9af4776374bff149 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Sat, 19 May 2018 19:29:21 +0200 Subject: [PATCH] FoxGlynnWeights: Zero-initialise structure Ensure that all members of the FoxGlynnWeights are zero-initialised, in particular the pointer to the weights array. --- prism/src/prism/prism.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prism/src/prism/prism.cc b/prism/src/prism/prism.cc index 61504cae..df915d55 100644 --- a/prism/src/prism/prism.cc +++ b/prism/src/prism/prism.cc @@ -105,7 +105,9 @@ void release_string_array_from_java(JNIEnv *env, jstring *strings_jstrings, cons EXPORT FoxGlynnWeights fox_glynn(double q_tmax, double underflow, double overflow, double accuracy) { - FoxGlynnWeights fgw; + // construct result struct and zero-initialise + // this ensures that fgw.weights = nullptr in case we return early on error + FoxGlynnWeights fgw{}; if (q_tmax == 0.0) { //FIXME: what should happen now?