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

11
ctx.cpp
View File

@@ -2206,6 +2206,17 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
if (resultPtrType != NULL)
Assert(ptrRefType != NULL);
llvm::PointerType *llvmPtrType =
llvm::dyn_cast<llvm::PointerType>(fullBasePtr->getType());
if (llvmPtrType != NULL) {
llvm::StructType *llvmStructType =
llvm::dyn_cast<llvm::StructType>(llvmPtrType->getElementType());
if (llvmStructType->isSized() == false) {
Assert(m->errorCount > 0);
return NULL;
}
}
// (Unfortunately) it's not required to pass a non-NULL ptrRefType, but
// if we have one, regularize into a pointer type.
const PointerType *ptrType = NULL;