[llvm] c2515a8 - [Bitcode] Add some missing GetTypeByID failure checks
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 26 07:52:50 PDT 2023
Author: Nikita Popov
Date: 2023-09-26T16:52:40+02:00
New Revision: c2515a8f2be5dd23354c9891f41ad104000f88c4
URL: https://github.com/llvm/llvm-project/commit/c2515a8f2be5dd23354c9891f41ad104000f88c4
DIFF: https://github.com/llvm/llvm-project/commit/c2515a8f2be5dd23354c9891f41ad104000f88c4.diff
LOG: [Bitcode] Add some missing GetTypeByID failure checks
Print an error instead of crashing.
Fixes https://github.com/llvm/llvm-project/issues/67388.
Added:
Modified:
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index b4b8690523244ef..2b52b46a4ee5c41 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1315,7 +1315,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
unsigned TyID = Record[0];
Type *Ty = Callbacks.GetTypeByID(TyID);
- if (Ty->isMetadataTy() || Ty->isVoidTy()) {
+ if (!Ty || Ty->isMetadataTy() || Ty->isVoidTy()) {
dropRecord();
break;
}
@@ -1366,7 +1366,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
unsigned TyID = Record[0];
Type *Ty = Callbacks.GetTypeByID(TyID);
- if (Ty->isMetadataTy() || Ty->isVoidTy())
+ if (!Ty || Ty->isMetadataTy() || Ty->isVoidTy())
return error("Invalid record");
Value *V = ValueList.getValueFwdRef(Record[1], Ty, TyID,
More information about the llvm-commits
mailing list