From 6ef60d82095281f90cd5e398a541abade4ed2b43 Mon Sep 17 00:00:00 2001 From: Alex Shelkovnykov Date: Tue, 28 Nov 2023 18:36:22 -0300 Subject: [PATCH] nock: fix slot access bug --- rust/ares/src/noun.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rust/ares/src/noun.rs b/rust/ares/src/noun.rs index 3e4b1c2..94d21a2 100644 --- a/rust/ares/src/noun.rs +++ b/rust/ares/src/noun.rs @@ -661,7 +661,7 @@ impl private::RawSlots for Cell { fn raw_slot(&self, axis: &BitSlice) -> Result { let mut noun: Noun = self.as_noun(); // Panic because all of the logic to guard against this is in Noun::RawSlots, Noun::Slots - let mut cursor = axis.last_one().expect("raw_slow somehow by-passed 0 check"); + let mut cursor = axis.last_one().expect("raw_slot somehow by-passed 0 check"); while cursor != 0 { cursor -= 1; @@ -1261,7 +1261,10 @@ pub trait Slots: private::RawSlots { * Retrieve component Noun at axis given as Atom, or fail with descriptive error */ fn slot_atom(&self, atom: Atom) -> Result { - self.raw_slot(atom.as_bitslice()) + match atom.as_either() { + Left(direct) => self.slot(direct.data()), + Right(indirect) => self.raw_slot(indirect.as_bitslice()), + } } }