From 054f5c963e4cbcdfd466c4232f8fff7d1d5a4cb7 Mon Sep 17 00:00:00 2001 From: yqco Date: Thu, 11 Aug 2016 04:22:37 -0600 Subject: [PATCH] Use verbose error message with DECORATE array indices --- src/thingdef/thingdef_expression.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 4af9e33c9..61660ffa8 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -3548,6 +3548,16 @@ FxExpression *FxArrayElement::Resolve(FCompileContext &ctx) delete this; return NULL; } + if (index->isConstant()) + { + unsigned indexval = static_cast(index)->GetValue().GetInt(); + if (indexval >= arraytype->ElementCount) + { + ScriptPosition.Message(MSG_ERROR, "Array index out of bounds"); + delete this; + return NULL; + } + } ValueType = arraytype->ElementType; if (ValueType->GetRegType() != REGT_INT && ValueType->GetRegType() != REGT_FLOAT) @@ -3583,10 +3593,6 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build) if (index->isConstant()) { unsigned indexval = static_cast(index)->GetValue().GetInt(); - if (indexval >= arraytype->ElementCount) - { - I_Error("Array index out of bounds"); - } indexval *= arraytype->ElementSize; if (AddressRequested)