spmi: fix prevEnviroment delete statement. (#13729)
authorSergey Andreenko <seandree@microsoft.com>
Fri, 1 Sep 2017 01:31:12 +0000 (18:31 -0700)
committerGitHub <noreply@github.com>
Fri, 1 Sep 2017 01:31:12 +0000 (18:31 -0700)
src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp

index eb3b189..82a7985 100644 (file)
@@ -6095,11 +6095,18 @@ bool MethodContext::wasEnviromentChanged()
     }
     if (changed)
     {
-        if (prevEnviroment == nullptr)
+        if (prevEnviroment != nullptr)
         {
             delete prevEnviroment;
         }
-        prevEnviroment = new DenseLightWeightMap<Agnostic_Environment>(*Environment);
+        if (Environment != nullptr)
+        {
+            prevEnviroment = new DenseLightWeightMap<Agnostic_Environment>(*Environment);
+        }
+        else
+        {
+            prevEnviroment = nullptr;
+        }
         return true;
     }
     return false;