don't allow [] as a stream alias, restore domain error on source sink for open/{3,4}
This commit is contained in:
@@ -1231,7 +1231,12 @@ impl MachineState {
|
|||||||
let alias = read_heap_cell!(self.store(MachineState::deref(self, alias)),
|
let alias = read_heap_cell!(self.store(MachineState::deref(self, alias)),
|
||||||
(HeapCellValueTag::Atom, (name, arity)) => {
|
(HeapCellValueTag::Atom, (name, arity)) => {
|
||||||
debug_assert_eq!(arity, 0);
|
debug_assert_eq!(arity, 0);
|
||||||
Some(name)
|
|
||||||
|
if name != atom!("[]") {
|
||||||
|
Some(name)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -2977,8 +2977,16 @@ impl MachineState {
|
|||||||
let options = self.to_stream_options(alias, eof_action, reposition, stream_type);
|
let options = self.to_stream_options(alias, eof_action, reposition, stream_type);
|
||||||
let src_sink = self.store(self.deref(self.registers[1]));
|
let src_sink = self.store(self.deref(self.registers[1]));
|
||||||
|
|
||||||
if let Some(atom_or_string) = self.value_to_str_like(src_sink) {
|
if let Some(str_like) = self.value_to_str_like(src_sink) {
|
||||||
let file_spec = self.atom_tbl.build_with(atom_or_string.as_str());
|
let file_spec = match str_like {
|
||||||
|
AtomOrString::Atom(atom) => {
|
||||||
|
atom
|
||||||
|
}
|
||||||
|
AtomOrString::String(string) => {
|
||||||
|
self.atom_tbl.build_with(&string)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut stream = self.stream_from_file_spec(file_spec, indices, &options)?;
|
let mut stream = self.stream_from_file_spec(file_spec, indices, &options)?;
|
||||||
|
|
||||||
*stream.options_mut() = options;
|
*stream.options_mut() = options;
|
||||||
|
|||||||
Reference in New Issue
Block a user