Skip to content

Commit

Permalink
clamp lower_bound_of_target_clause index (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthom committed Dec 18, 2023
1 parent 3353306 commit 299df50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/machine/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn lower_bound_of_target_clause(skeleton: &mut PredicateSkeleton, target_pos: us

let index = target_pos - 1;

if let Some(index_loc) = skeleton.clauses[index]
let index = if let Some(index_loc) = skeleton.clauses[index]
.opt_arg_index_key
.switch_on_term_loc()
{
Expand All @@ -66,7 +66,9 @@ fn lower_bound_of_target_clause(skeleton: &mut PredicateSkeleton, target_pos: us
}
} else {
index
}
};

index.clamp(0, skeleton.clauses.len() - 1)
}

fn derelictize_try_me_else(
Expand Down
10 changes: 3 additions & 7 deletions src/machine/load_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,9 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
if !code_index.is_undefined() && !code_index.is_dynamic_undefined() {
let old_index_ptr = code_index.replace(IndexPtr::undefined());

self.payload
.retraction_info
.push_record(RetractionRecord::ReplacedModulePredicate(
module_name,
*key,
old_index_ptr,
));
self.payload.retraction_info.push_record(
RetractionRecord::ReplacedModulePredicate(module_name, *key, old_index_ptr),
);
}
}

Expand Down

0 comments on commit 299df50

Please sign in to comment.