Skip to content

Commit 373b08a

Browse files
committed
fix off-by-one error caused logtalk test to crash
1 parent a715496 commit 373b08a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/machine/compile.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ fn lower_bound_of_target_clause(skeleton: &mut PredicateSkeleton, target_pos: us
4747
return 0;
4848
}
4949

50+
debug_assert!(skeleton.clauses.len() >= 2);
51+
5052
let index = target_pos - 1;
5153

5254
let index = if let Some(index_loc) = skeleton.clauses[index]
@@ -68,7 +70,7 @@ fn lower_bound_of_target_clause(skeleton: &mut PredicateSkeleton, target_pos: us
6870
index
6971
};
7072

71-
index.clamp(0, skeleton.clauses.len() - 1)
73+
index.clamp(0, skeleton.clauses.len() - 2)
7274
}
7375

7476
fn derelictize_try_me_else(
@@ -1518,6 +1520,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
15181520
} = self.compile_standalone_clause(clause, settings)?;
15191521

15201522
let code_len = self.wam_prelude.code.len();
1523+
15211524
standalone_skeleton.clauses[0].clause_start += code_len;
15221525

15231526
let skeleton = match self

0 commit comments

Comments
 (0)