Fix crashes when input program tried to access undefined struct types.
(This in particular would happen when there was an error in the body of a struct definition and we were left with an UndefinedStructType and then later tried to do loads/stores from/to it.) Issue #356.
This commit is contained in:
12
ctx.cpp
12
ctx.cpp
@@ -2484,6 +2484,12 @@ FunctionEmitContext::LoadInst(llvm::Value *ptr, llvm::Value *mask,
|
||||
AssertPos(currentPos, ptrType != NULL);
|
||||
}
|
||||
|
||||
if (CastType<UndefinedStructType>(ptrType->GetBaseType())) {
|
||||
Error(currentPos, "Unable to load to undefined struct type \"%s\".",
|
||||
ptrType->GetBaseType()->GetString().c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ptrType->IsUniformType()) {
|
||||
if (ptrType->IsSlice()) {
|
||||
return loadUniformFromSOA(ptr, mask, ptrType, name);
|
||||
@@ -2964,6 +2970,12 @@ FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr,
|
||||
AssertPos(currentPos, ptrType != NULL);
|
||||
}
|
||||
|
||||
if (CastType<UndefinedStructType>(ptrType->GetBaseType())) {
|
||||
Error(currentPos, "Unable to store to undefined struct type \"%s\".",
|
||||
ptrType->GetBaseType()->GetString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Figure out what kind of store we're doing here
|
||||
if (ptrType->IsUniformType()) {
|
||||
if (ptrType->IsSlice())
|
||||
|
||||
Reference in New Issue
Block a user