From 09abc0c75a14e7b5ee99173f31b717e452e056f9 Mon Sep 17 00:00:00 2001
From: Richard Berger <richard.berger@temple.edu>
Date: Thu, 29 Nov 2018 00:41:40 -0500
Subject: [PATCH] Fix memory leak in Variable::compute_atom

---
 src/variable.cpp | 1 +
 src/variable.h   | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/src/variable.cpp b/src/variable.cpp
index f83d3ebc20..9c837719f2 100644
--- a/src/variable.cpp
+++ b/src/variable.cpp
@@ -971,6 +971,7 @@ void Variable::compute_atom(int ivar, int igroup,
   } else vstore = reader[ivar]->fixstore->vstore;
 
   if (result == NULL) {
+    if (style[ivar] == ATOM) free_tree(tree);
     eval_in_progress[ivar] = 0;
     return;
   }
diff --git a/src/variable.h b/src/variable.h
index b20eb7e6b9..9a6aa4c0b4 100644
--- a/src/variable.h
+++ b/src/variable.h
@@ -92,6 +92,13 @@ class Variable : protected Pointers {
     int nextra;            // # of additional args beyond first 2
     Tree *first,*second;   // ptrs further down tree for first 2 args
     Tree **extra;          // ptrs further down tree for nextra args
+
+    Tree() :
+      array(NULL), iarray(NULL), barray(NULL),
+      selfalloc(0), nextra(0),
+      first(NULL), second(NULL), extra(NULL)
+    {
+    }
   };
 
   int compute_python(int);
-- 
GitLab