Skip to content

Commit

Permalink
Fix possible access to fromspace in string_index_ignore_case
Browse files Browse the repository at this point in the history
We already correctly root Haystack but were assigning it to Hs_or_gic before
that, so that one could have been outdated. Move Hs_or_gic's initialization to
a place where Haystack is already stable.
  • Loading branch information
niner committed Jul 27, 2019
1 parent 6730e51 commit 07f6305
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/strings/ops.c
Expand Up @@ -1343,7 +1343,7 @@ static MVMint64 string_index_ignore_case(MVMThreadContext *tc, MVMString *Haysta
MVMint64 H_expansion;
MVMint64 return_val = -1;
int is_gic = Haystack->body.storage_type == MVM_STRING_STRAND ? 1 : 0;
void *Hs_or_gic = Haystack;
void *Hs_or_gic;
MVM_string_check_arg(tc, Haystack, ignoremark ? "index ignore case ignore mark search target" : "index ignore case search target");
MVM_string_check_arg(tc, needle, ignoremark ? "index ignore case ignore mark search term" : "index ignore case search term");
H_graphs = MVM_string_graphs_nocheck(tc, Haystack);
Expand Down Expand Up @@ -1372,6 +1372,9 @@ static MVMint64 string_index_ignore_case(MVMThreadContext *tc, MVMString *Haysta
Hs_or_gic = alloca(sizeof(MVMGraphemeIter_cached));
MVM_string_gi_cached_init(tc, Hs_or_gic, Haystack, start);
}
else {
Hs_or_gic = Haystack;
}
while (index <= H_graphs) {
H_expansion = string_equal_at_ignore_case_INTERNAL_loop(tc, Hs_or_gic, needle_fc, index, H_graphs, n_fc_graphs, ignoremark, ignorecase, is_gic);
if (0 <= H_expansion)
Expand Down

0 comments on commit 07f6305

Please sign in to comment.