diff --git a/libs/ardour/ardour/export_filename.h b/libs/ardour/ardour/export_filename.h
index 7eacc11..3761f97 100644
--- a/libs/ardour/ardour/export_filename.h
+++ b/libs/ardour/ardour/export_filename.h
@@ -112,8 +112,7 @@ class LIBARDOUR_API ExportFilename {
 	TimeFormat time_format;
 
 	std::string get_formatted_time (std::string const & format) const;
-	// Due to the static allocation used in strftime(), no destructor or copy-ctor is needed for this
-	struct tm * time_struct;
+	struct tm time_struct;
 
 	ExportTimespanPtr timespan;
 	ExportChannelConfigPtr channel_config;
diff --git a/libs/ardour/export_filename.cc b/libs/ardour/export_filename.cc
index 077106a..f0dda12 100644
--- a/libs/ardour/export_filename.cc
+++ b/libs/ardour/export_filename.cc
@@ -62,7 +62,12 @@ ExportFilename::ExportFilename (Session & session) :
 {
 	time_t rawtime;
 	std::time (&rawtime);
-	time_struct = localtime (&rawtime);
+
+#ifdef PLATFORM_WINDOWS
+	localtime_s (&rawtime, &time_struct);
+#else
+	localtime_r (&rawtime, &time_struct);
+#endif
 
 	folder = session.session_directory().export_path();
 
@@ -319,7 +324,7 @@ string
 ExportFilename::get_formatted_time (string const & format) const
 {
 	char buffer [80];
-	strftime (buffer, 80, format.c_str(), time_struct);
+	strftime (buffer, 80, format.c_str(), &time_struct);
 
 	string return_value (buffer);
 	return return_value;
