Skip to content

Commit

Permalink
Merge pull request #2344 from XrXr/overlapping-memcpy
Browse files Browse the repository at this point in the history
Fix overlapping memcpy
  • Loading branch information
kddnewton authored Feb 2, 2024
2 parents 5d94655 + 719f54f commit cd312d3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -18061,7 +18061,9 @@ pm_parser_errors_format_sort(const pm_list_t *error_list, const pm_newline_list_

// Now we're going to shift all of the errors after this one down one
// index to make room for the new error.
memcpy(&errors[index + 1], &errors[index], sizeof(pm_error_t) * (error_list->size - index - 1));
if (index + 1 < error_list->size) {
memmove(&errors[index + 1], &errors[index], sizeof(pm_error_t) * (error_list->size - index - 1));
}

// Finally, we'll insert the error into the array.
uint32_t column_end;
Expand Down

0 comments on commit cd312d3

Please sign in to comment.