From 3ebf8d5db9c3b87f45f7888aa022958fb945df4f Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Mon, 17 Jan 2022 17:58:09 -0700 Subject: [PATCH] clear alias in close before resetting the stream to null (#1231) --- src/lib/builtins.pl | 3 ++- src/machine/system_calls.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index 4619bfad..a060a69c 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -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) ) ). diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 98130bc2..c9d988f9 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -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); -- 2.54.0