[clang] [clang][ASTImporter] fix assert fail due to offset overflow (PR #79084)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 26 09:26:59 PST 2024


================
@@ -9896,9 +9903,13 @@ Expected<FileID> ASTImporter::Import(FileID FromID, bool IsBuiltin) {
         // FIXME: The filename may be a virtual name that does probably not
         // point to a valid file and we get no Entry here. In this case try with
         // the memory buffer below.
-        if (Entry)
+        if (Entry) {
+          if (isBufferSizeOverflow(ToSM, Entry->getSize()))
+            return llvm::make_error<ASTImportError>(
+                ASTImportError::UnsupportedConstruct);
----------------
balazske wrote:

It is better to use `Unknown` as error kind here (it is used already in this function), or add a new type of error to `ASTImportError::ErrorKind`.

https://github.com/llvm/llvm-project/pull/79084


More information about the cfe-commits mailing list