Skip to content

Commit

Permalink
iASL: Fix issue with possible freopen failure.
Browse files Browse the repository at this point in the history
An attempted workaround for the "freopen closes the input file even
if it later fails" issue was not portable. This change fixes
the problem by emitting an error message to stdout and exiting.
Part of ACPICA BZ 1130.
  • Loading branch information
acpibob committed May 19, 2015
1 parent 31969e9 commit ecb91f4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions source/compiler/aslfiles.c
Expand Up @@ -655,22 +655,22 @@ FlOpenMiscOutputFiles (

/* Open the debug file as STDERR, text mode */

/* TBD: hide this behind a FlReopenFile function */

Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
freopen (Filename, "w+t", stderr);

if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
{
/*
* A problem with freopen is that on error,
* we no longer have stderr.
* A problem with freopen is that on error, we no longer
* have stderr and cannot emit normal error messages.
* Emit error to stdout, close files, and exit.
*/
Gbl_DebugFlag = FALSE;
memcpy (stderr, stdout, sizeof (FILE));
FlFileError (ASL_FILE_DEBUG_OUTPUT, ASL_MSG_DEBUG_FILENAME);
AslAbort ();
fprintf (stdout,
"\nCould not open debug output file: %s\n\n", Filename);

CmCleanupAndExit ();
exit (1);
}

AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
Expand Down

0 comments on commit ecb91f4

Please sign in to comment.