Skip to content

Commit

Permalink
fix segfault (openvinotoolkit#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-esir authored Aug 23, 2024
1 parent 590fc06 commit f7cd828
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,15 @@ std::pair<size_t, size_t> PCRE2Wrapper::match(const std::string& str, size_t cur
pcre2_match_data_free(match_data);
return {SIZE_MAX, SIZE_MAX};
}
// If we survived the previous IF there is at least one match, no out of bound can happen here.

// At this point there is at least one match, no out of bound can happen here.
// If ovector do not contain values early return is done and the code below is not run.
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);

std::pair<size_t, size_t> res = {ovector[0], ovector[1]};

// Free only after copying results from match_data to res;
pcre2_match_data_free(match_data);
return {ovector[0], ovector[1]};
return res;
}


Expand Down

0 comments on commit f7cd828

Please sign in to comment.