diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 24e541a36..273d4e498 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -2304,6 +2304,7 @@ ExpEmit FxPreIncrDecr::Emit(VMFunctionBuilder *build) } pointer.Free(build); + value.Target = false; // This is for 'unrequesting' the address of a register variable. If not done here, passing a preincrement expression to a function will generate bad code. return value; } @@ -7406,7 +7407,16 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build) if (arrayispointer) { - arraytype = static_cast(Array->ValueType->toPointer()->PointedType); + auto ptr = Array->ValueType->toPointer(); + if (ptr != nullptr) + { + arraytype = static_cast(ptr->PointedType); + } + else + { + ScriptPosition.Message(MSG_ERROR, "Internal error when generating code for array access"); + return ExpEmit(); + } } else {