Fix various malformed program crashes.

This commit is contained in:
Matt Pharr
2012-05-18 10:44:45 -07:00
parent 8d3ac3ac1e
commit 72c41f104e
3 changed files with 24 additions and 2 deletions

View File

@@ -520,7 +520,10 @@ Target::StructOffset(llvm::Type *type, int element,
Assert(td != NULL);
llvm::StructType *structType =
llvm::dyn_cast<llvm::StructType>(type);
Assert(structType != NULL);
if (structType == NULL || structType->isSized() == false) {
Assert(m->errorCount > 0);
return NULL;
}
const llvm::StructLayout *sl = td->getStructLayout(structType);
Assert(sl != NULL);