From: Mark Thom Date: Tue, 18 Jan 2022 00:58:09 +0000 (-0700) Subject: clear alias in close before resetting the stream to null (#1231) X-Git-Tag: v0.9.0^2~57 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=3ebf8d5db9c3b87f45f7888aa022958fb945df4f;p=scryer-prolog.git clear alias in close before resetting the stream to null (#1231) --- 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);