Skip to content

Commit e6aa54c

Browse files
committed
Fix a failure when std::getenv("TMPDIR") returns nullptr.
1 parent 96515a0 commit e6aa54c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/tools/CommandLine.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ void Convert(std::string fileName) {
9191
const std::string tempFileName = std::tmpnam(nullptr);
9292
#else
9393
// std::tmpnam is deprecated
94-
std::string tempFileName = std::getenv("TMPDIR");
94+
std::string tempFileName;
95+
const char* tmpDirEnv = std::getenv("TMPDIR");
96+
if (tmpDirEnv != nullptr) {
97+
tempFileName = tmpDirEnv;
98+
}
9599
#ifdef P_tmpdir
96100
if (tempFileName.empty()) {
97101
tempFileName = P_tmpdir;

0 commit comments

Comments
 (0)