Fix crashes from malformed programs.

This commit is contained in:
Matt Pharr
2011-12-12 13:35:24 -08:00
parent 46bfef3fce
commit 5b48354d9a
2 changed files with 8 additions and 1 deletions

View File

@@ -1850,6 +1850,11 @@ llvm::Value *
FunctionEmitContext::AllocaInst(LLVM_TYPE_CONST llvm::Type *llvmType,
const char *name, int align,
bool atEntryBlock) {
if (llvmType == NULL) {
assert(m->errorCount > 0);
return NULL;
}
llvm::AllocaInst *inst = NULL;
if (atEntryBlock) {
// We usually insert it right before the jump instruction at the

View File

@@ -3350,11 +3350,13 @@ StructMemberExpr::GetType() const {
return NULL;
const Type *elementType = structType->GetElementType(identifier);
if (elementType == NULL)
if (elementType == NULL) {
Error(identifierPos,
"Element name \"%s\" not present in struct type \"%s\".%s",
identifier.c_str(), structType->GetString().c_str(),
getCandidateNearMatches().c_str());
return NULL;
}
const PointerType *pt = dynamic_cast<const PointerType *>(expr->GetType());
if (structType->IsVaryingType() ||