commit 7008417beb741576eaf916bd0045a03b6a703897
parent d33495a4b9b2326a315f8b391e98bff55375c37a
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Sat, 7 Jan 2017 01:43:44 -0800
inst: handle tmpnam failure more gracefully
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/inst_frontend.cc b/inst_frontend.cc
@@ -217,6 +217,12 @@ InstFrontend::save_if_srcfile(char *arg)
!ends_with(arg, ".cpp") && !ends_with(arg, ".cxx"))
return;
+ char *dst_fn;
+ if ((dst_fn = std::tmpnam(NULL)) == NULL) {
+ m_log << "tmpnam failed." << std::endl;
+ return;
+ }
+
m_source_files.push_back(arg);
m_log << "Found source file '" << arg << "'" << std::endl;
@@ -225,10 +231,6 @@ InstFrontend::save_if_srcfile(char *arg)
// completely different file.
return;
- char *dst_fn;
- if ((dst_fn = std::tmpnam(NULL)) == NULL)
- err(1, "tmpnam");
-
copy_file(dst_fn, arg);
m_temp_file_map[arg] = dst_fn;
}