Skip to content

Commit ad8d2e9

Browse files
committed
Restore stdout and stderr to avoid segfault
1 parent 5d87dcc commit ad8d2e9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ int main(int argc, char* argv[])
100100
const std::filesystem::path execPath = std::filesystem::path(argv[0]).parent_path();
101101
const std::filesystem::path configFile = execPath / "config" / "default.json";
102102

103+
auto oldCoutBuf = std::cout.rdbuf();
104+
auto oldCerrBuf = std::cerr.rdbuf();
105+
103106
std::ostringstream local;
104107
std::cout.rdbuf(local.rdbuf());
105108
std::cerr.rdbuf(local.rdbuf());
@@ -136,6 +139,9 @@ int main(int argc, char* argv[])
136139
out.close();
137140
}
138141

142+
std::cout.rdbuf(oldCoutBuf);
143+
std::cerr.rdbuf(oldCerrBuf);
144+
139145
return 0;
140146
}
141147

0 commit comments

Comments
 (0)