Skip to content

Commit

Permalink
explicitly check if ERROR_OUTPUT is a stream object before attempting…
Browse files Browse the repository at this point in the history
… to open it
  • Loading branch information
embray committed Nov 23, 2018
1 parent 3eb2f2a commit 2949b24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

static Obj ErrorInner;
static Obj ERROR_OUTPUT = NULL;
static Obj IsOutputStream;


/****************************************************************************
Expand All @@ -57,7 +58,9 @@ UInt OpenErrorOutput( void )
ret = OpenOutput(CONST_CSTR_STRING(ERROR_OUTPUT));
}
else {
ret = OpenOutputStream(ERROR_OUTPUT);
if (CALL_1ARGS(IsOutputStream, ERROR_OUTPUT) == True) {
ret = OpenOutputStream(ERROR_OUTPUT);
}
}
}

Expand Down Expand Up @@ -618,6 +621,7 @@ static Int InitKernel(StructInitInfo * module)
InitHdlrFuncsFromTable(GVarFuncs);

ImportFuncFromLibrary("ErrorInner", &ErrorInner);
ImportFuncFromLibrary("IsOutputStream", &IsOutputStream);
ImportGVarFromLibrary("ERROR_OUTPUT", &ERROR_OUTPUT);

// return success
Expand Down

0 comments on commit 2949b24

Please sign in to comment.