Skip to content

Commit 7b997d5

Browse files
Fixed potential crash in the generator (#615)
Signed-off-by: Shaobo He <[email protected]>
1 parent b64cce3 commit 7b997d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cedar-policy-generators/src/schema.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,9 @@ impl Schema {
10691069
-> Result<Vec<ast::InternalName>> {
10701070
// Pre-select the number of entity types (minimum 1), then randomly select that many indices
10711071
let num = u
1072-
.int_in_range(1..=(entity_types.len() % Self::PER_ACTION_REQUEST_ENV_LIMIT))
1072+
.int_in_range(
1073+
1..=std::cmp::min(entity_types.len(), Self::PER_ACTION_REQUEST_ENV_LIMIT),
1074+
)
10731075
.unwrap();
10741076
let mut indices: Vec<usize> = (0..entity_types.len()).collect();
10751077
let mut selected_indices = Vec::with_capacity(num);

0 commit comments

Comments
 (0)