From 3508eca33768bb715b5d6b24f3cb49ffe4033dc6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer <akohlmey@gmail.com> Date: Wed, 28 Nov 2018 18:49:37 -0500 Subject: [PATCH] make sure all local Tree pointers are initialized, either to a newly allocated Tree() or NULL --- src/variable.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/variable.cpp b/src/variable.cpp index af5f647b74..f83d3ebc20 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -956,7 +956,7 @@ double Variable::compute_equal(char *str) void Variable::compute_atom(int ivar, int igroup, double *result, int stride, int sumflag) { - Tree *tree; + Tree *tree = NULL; double *vstore; if (eval_in_progress[ivar]) @@ -1028,7 +1028,7 @@ void Variable::compute_atom(int ivar, int igroup, int Variable::compute_vector(int ivar, double **result) { - Tree *tree; + Tree *tree = NULL; if (vecs[ivar].currentstep == update->ntimestep) { *result = vecs[ivar].values; return vecs[ivar].n; @@ -1215,7 +1215,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) // evaluate contents and push on stack if (tree) { - Tree *newtree; + Tree *newtree = NULL; evaluate(contents,&newtree,ivar); treestack[ntreestack++] = newtree; } else argstack[nargstack++] = evaluate(contents,NULL,ivar); @@ -1915,7 +1915,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Atom-style variable in " "vector-style variable formula",ivar); - Tree *newtree; + Tree *newtree = NULL; evaluate(data[ivar][0],&newtree,ivar); treestack[ntreestack++] = newtree; @@ -3325,7 +3325,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree, char *args[MAXFUNCARG]; int narg = parse_args(contents,args); - Tree *newtree; + Tree *newtree = NULL; double value1,value2; double values[MAXFUNCARG-2]; @@ -3333,7 +3333,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree, newtree = new Tree(); newtree->first = newtree->second = NULL; newtree->nextra = 0; - Tree *argtree; + Tree *argtree = NULL; evaluate(args[0],&argtree,ivar); newtree->first = argtree; if (narg > 1) { -- GitLab