Skip to content
Snippets Groups Projects
Commit 8fd59d73 authored by Chandler Carruth's avatar Chandler Carruth
Browse files

[UB] Avoid a really broken call to realloc that would later result in

a bad call to memcpy.

When we only have a buffer from one of the two reparse calls, we can
just return that buffer rather than going through the realloc/memcpy
dance.

Found with UBsan.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243950 91177308-0d34-0410-b5e6-96231b3b80d8
parent 49ebe63b
No related branches found
No related tags found
No related merge requests found
......@@ -255,6 +255,17 @@ static int parse_remapped_files_with_try(int try_idx,
if (ret)
return ret;
if (num_unsaved_files_no_try_idx == 0) {
*unsaved_files = unsaved_files_try_idx;
*num_unsaved_files = num_unsaved_files_try_idx;
return 0;
}
if (num_unsaved_files_try_idx == 0) {
*unsaved_files = unsaved_files_no_try_idx;
*num_unsaved_files = num_unsaved_files_no_try_idx;
return 0;
}
*num_unsaved_files = num_unsaved_files_no_try_idx + num_unsaved_files_try_idx;
*unsaved_files
= (struct CXUnsavedFile *)realloc(unsaved_files_no_try_idx,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment