diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 088a636a788063af675e5281241f435c392b939e..ac99d35683272b5eefa2d36a27704adec2fc9e4b 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -315,7 +315,10 @@ ParsingDriver::add_expression_variable(string *name)
 void
 ParsingDriver::declare_nonstationary_var(string *name, string *tex_name)
 {
-  declare_endogenous(new string(*name), tex_name);
+  if (tex_name != NULL)
+    declare_endogenous(new string(*name), new string(*tex_name));
+  else
+    declare_endogenous(new string(*name), tex_name);
   declared_nonstationary_vars.push_back(mod_file->symbol_table.getID(*name));
   mod_file->nonstationary_variables = true;
   delete name;