diff --git a/src/primitives/correction.rs b/src/primitives/correction.rs index 9e0f534d..3edc0454 100644 --- a/src/primitives/correction.rs +++ b/src/primitives/correction.rs @@ -65,8 +65,17 @@ pub trait CorrectableError { /// Wrapper around [`Self::residue_error`] that outputs a correction context. /// + /// Will return None if the error is not a correctable one, or if the **alloc** + /// feature is disabled and the checksum is too large. See the documentation + /// for [`NO_ALLOC_MAX_LENGTH`] for more information. + /// /// This is the function that users should call. fn correction_context(&self) -> Option> { + #[cfg(not(feature = "alloc"))] + if Ck::CHECKSUM_LENGTH >= NO_ALLOC_MAX_LENGTH { + return None; + } + self.residue_error().map(|e| Corrector { residue: e.residue(), phantom: PhantomData }) } } diff --git a/src/primitives/decode.rs b/src/primitives/decode.rs index f4cadd57..b4ca5e38 100644 --- a/src/primitives/decode.rs +++ b/src/primitives/decode.rs @@ -1028,7 +1028,9 @@ impl InvalidResidueError { /// holds the target residue but this doesn't help), the caller will need /// to obtain the checksum from somewhere else in order to make use of this. /// - /// Not public because [`Polynomial`] is a private type. + /// Not public because [`Polynomial`] is a private type, and because the + /// subtraction will panic if this is called without checking has_data + /// on the FieldVecs. pub(super) fn residue(&self) -> Polynomial { self.actual.clone() - &self.target } }