Coverity-344513: Fix use-after-free in unit test error condition.

This commit is contained in:
Micah Snyder
2023-04-18 14:53:57 -07:00
committed by Micah Snyder
parent e33797d11e
commit a08377f9cf

View File

@@ -2055,7 +2055,9 @@ int main(void)
srunner_set_log(sr, OBJDIR PATHSEP "test.log");
if (freopen(OBJDIR PATHSEP "test-stderr.log", "w+", stderr) == NULL) {
fputs("Unable to redirect stderr!\n", stderr);
// The stderr FILE pointer may be closed by `freopen()` even if redirecting to the log file files.
// So we will output the error message to stdout instead.
fputs("Unable to redirect stderr!\n", stdout);
}
cl_debug();