When given unsaved files in clang_createTranslationUnitFromSourceFile,
copy the source buffers provided rather than referencing them directly, so that the caller can free those buffers immediately after calling clang_createTranslationUnitFromSourceFile(). Otherwise, we risk hitting those buffers later (when building source ranges, forming diagnostics, etc.). llvm-svn: 97296
This commit is contained in:
@@ -439,6 +439,7 @@ static void InitializeFileRemapping(Diagnostic &Diags,
|
||||
if (!FromFile) {
|
||||
Diags.Report(diag::err_fe_remap_missing_from_file)
|
||||
<< Remap->first;
|
||||
delete Remap->second;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -477,7 +478,7 @@ static void InitializeFileRemapping(Diagnostic &Diags,
|
||||
= llvm::MemoryBuffer::getFile(ToFile->getName(), &ErrorStr);
|
||||
if (!Buffer) {
|
||||
Diags.Report(diag::err_fe_error_opening)
|
||||
<< Remap->second << ErrorStr;
|
||||
<< Remap->second << ErrorStr;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user