Skip to content

Commit

Permalink
Fix bounds issue in unicode collation (though not possible to trigger)
Browse files Browse the repository at this point in the history
This can't be triggered since we don't have anywhere near 10 graphemes
in a collation rule, but change it anyway. Since we increase the value
of i immediately after the conditional, that could make i == 10 for an
array with only 10 elements and cause it to go past its bounds.
  • Loading branch information
samcv committed May 30, 2018
1 parent e2afa7f commit 26ab289
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/strings/unicode_ops.c
Expand Up @@ -408,7 +408,7 @@ static MVMint64 collation_push_cp (MVMThreadContext *tc, collation_stack *stack,
last_good_result = -1;
MVMint64 i, result = query;
DEBUG_PRINT_SUB_NODE(main_nodes[query]);
for (i = 0; result != -1 && MVM_string_ci_has_more(tc, ci) && i < 10;) {
for (i = 0; result != -1 && MVM_string_ci_has_more(tc, ci) && i < 9;) {
i++;
/* Only grab a codepoint if it doesn't already exist in the array */
if (cp_num <= i) {
Expand Down

0 comments on commit 26ab289

Please sign in to comment.