Skip to content

Commit

Permalink
Fix stderr redirection
Browse files Browse the repository at this point in the history
You cannot modify dereferenced FILE, this is UB. FILE may also be
opaque type so this code may not compile (and in fact it doesn't
compile on DragonFlyBSD). freopen is quite enough to do the thing.
  • Loading branch information
AMDmi3 committed Mar 27, 2015
1 parent 15fb9b6 commit b63c4a6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/posix/OSPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ void RedirectStdio()
FILE *f;

f = freopen(output_path.c_str(), "w", stderr);
if (!f)
f = fopen(output_path.c_str(), "w");
if (!f)
Output("ERROR: Couldn't redirect output to '%s': %s\n", output_path.c_str(), strerror(errno));
else {
else
setvbuf(f, 0, _IOLBF, BUFSIZ);
*stderr = *f;
}
}

void EnableFPE()
Expand Down

0 comments on commit b63c4a6

Please sign in to comment.