clear alias in close before resetting the stream to null (#1231)

This commit is contained in:
Mark Thom
2022-01-17 17:58:09 -07:00
parent 89e33903b2
commit 3ebf8d5db9
2 changed files with 4 additions and 3 deletions

View File

@@ -1468,7 +1468,8 @@ open(SourceSink, Mode, Stream, StreamOptions) :-
atom(SourceSink) ->
atom_chars(SourceSink, SourceSinkString)
; SourceSink = SourceSinkString
), '$open'(SourceSinkString, Mode, Stream, Alias, EOFAction, Reposition, Type)
),
'$open'(SourceSinkString, Mode, Stream, Alias, EOFAction, Reposition, Type)
)
).

View File

@@ -2728,12 +2728,12 @@ impl Machine {
}
if !stream.is_stdin() && !stream.is_stdout() && !stream.is_stderr() {
let close_result = stream.close();
if let Some(alias) = stream.options().get_alias() {
self.indices.stream_aliases.remove(&alias);
}
let close_result = stream.close();
if let Err(_) = close_result {
let stub = functor_stub(atom!("close"), 1);
let addr = stream_as_cell!(stream);