From 918a247c0de4d87b7bf6c7c51fee8af76fe644e9 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Thu, 26 Mar 2015 17:20:34 -0400 Subject: [PATCH] - Assign the fileDepth of a constant earlier to avoid uninitialized value when evaluating constant. --- parse.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/parse.c b/parse.c index 1832655..b682480 100644 --- a/parse.c +++ b/parse.c @@ -1190,11 +1190,6 @@ static void OuterDefine(boolean force) force ? "(forced) " : ""); TK_NextTokenMustBe(TK_IDENTIFIER, ERR_INVALID_IDENTIFIER); sym = SY_InsertGlobalUnique(tk_String, SY_CONSTANT); - TK_NextToken(); - value = EvalConstExpression(); - MS_Message(MSG_DEBUG, "Constant value: %d\n", value); - sym->info.constant.value = value; - sym->info.constant.strValue = pa_ConstExprIsString ? strdup(STR_Get(value)) : NULL; // Defines inside an import are deleted when the import is popped. if(ImportMode != IMPORT_Importing || force) { @@ -1204,6 +1199,12 @@ static void OuterDefine(boolean force) { sym->info.constant.fileDepth = TK_GetDepth(); } + + TK_NextToken(); + value = EvalConstExpression(); + MS_Message(MSG_DEBUG, "Constant value: %d\n", value); + sym->info.constant.value = value; + sym->info.constant.strValue = pa_ConstExprIsString ? strdup(STR_Get(value)) : NULL; } //==========================================================================