Fix various malformed program crashes.
This commit is contained in:
11
ctx.cpp
11
ctx.cpp
@@ -2206,6 +2206,17 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
if (resultPtrType != NULL)
|
if (resultPtrType != NULL)
|
||||||
Assert(ptrRefType != 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
|
// (Unfortunately) it's not required to pass a non-NULL ptrRefType, but
|
||||||
// if we have one, regularize into a pointer type.
|
// if we have one, regularize into a pointer type.
|
||||||
const PointerType *ptrType = NULL;
|
const PointerType *ptrType = NULL;
|
||||||
|
|||||||
10
expr.cpp
10
expr.cpp
@@ -4813,6 +4813,9 @@ MemberExpr::GetValue(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
llvm::Value *mask = NULL;
|
llvm::Value *mask = NULL;
|
||||||
if (lvalue == NULL) {
|
if (lvalue == NULL) {
|
||||||
|
if (m->errorCount > 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// As in the array case, this may be a temporary that hasn't hit
|
// As in the array case, this may be a temporary that hasn't hit
|
||||||
// memory; get the full value and stuff it into a temporary array
|
// memory; get the full value and stuff it into a temporary array
|
||||||
// so that we can index from there...
|
// so that we can index from there...
|
||||||
@@ -4889,6 +4892,10 @@ MemberExpr::GetLValue(FunctionEmitContext *ctx) const {
|
|||||||
llvm::Value *ptr = ctx->AddElementOffset(basePtr, elementNumber,
|
llvm::Value *ptr = ctx->AddElementOffset(basePtr, elementNumber,
|
||||||
exprLValueType,
|
exprLValueType,
|
||||||
basePtr->getName().str().c_str());
|
basePtr->getName().str().c_str());
|
||||||
|
if (ptr == NULL) {
|
||||||
|
Assert(m->errorCount > 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ptr = lAddVaryingOffsetsIfNeeded(ctx, ptr, GetLValueType());
|
ptr = lAddVaryingOffsetsIfNeeded(ctx, ptr, GetLValueType());
|
||||||
|
|
||||||
@@ -6606,7 +6613,8 @@ TypeCastExpr::GetValue(FunctionEmitContext *ctx) const {
|
|||||||
// The only legal type conversions for structs are to go from a
|
// The only legal type conversions for structs are to go from a
|
||||||
// uniform to a varying instance of the same struct type.
|
// uniform to a varying instance of the same struct type.
|
||||||
Assert(toStruct->IsVaryingType() && fromStruct->IsUniformType() &&
|
Assert(toStruct->IsVaryingType() && fromStruct->IsUniformType() &&
|
||||||
Type::Equal(toStruct, fromStruct->GetAsVaryingType()));
|
Type::EqualIgnoringConst(toStruct,
|
||||||
|
fromStruct->GetAsVaryingType()));
|
||||||
|
|
||||||
llvm::Value *origValue = expr->GetValue(ctx);
|
llvm::Value *origValue = expr->GetValue(ctx);
|
||||||
if (!origValue)
|
if (!origValue)
|
||||||
|
|||||||
5
ispc.cpp
5
ispc.cpp
@@ -520,7 +520,10 @@ Target::StructOffset(llvm::Type *type, int element,
|
|||||||
Assert(td != NULL);
|
Assert(td != NULL);
|
||||||
llvm::StructType *structType =
|
llvm::StructType *structType =
|
||||||
llvm::dyn_cast<llvm::StructType>(type);
|
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);
|
const llvm::StructLayout *sl = td->getStructLayout(structType);
|
||||||
Assert(sl != NULL);
|
Assert(sl != NULL);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user