From 53bc13ce011473f976f736dce9525bfa5b3e95ca Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Tue, 16 Jun 2015 04:23:42 -0400 Subject: [PATCH] compiler/libec: Null checks --- compiler/libec/src/pass0.ec | 2 +- compiler/libec/src/pass1.ec | 2 +- compiler/libec/src/pass2.ec | 9 ++++++--- compiler/libec/src/pass3.ec | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/libec/src/pass0.ec b/compiler/libec/src/pass0.ec index 3a18141..1496fe8 100644 --- a/compiler/libec/src/pass0.ec +++ b/compiler/libec/src/pass0.ec @@ -428,7 +428,7 @@ static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol classType = regClass.type; // PUBLISHING CHECK ON BASE CLASS - if(inCompiler) + if(inCompiler && regClass.base) // The base check saves a crash trying to inherit from itself { yylloc = loc; diff --git a/compiler/libec/src/pass1.ec b/compiler/libec/src/pass1.ec index 0370d4a..7c0f957 100644 --- a/compiler/libec/src/pass1.ec +++ b/compiler/libec/src/pass1.ec @@ -1510,7 +1510,7 @@ static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol // int64 value { char * temp; - if(!strcmp(regClass.dataTypeString, "uint64")) + if(regClass.dataTypeString && !strcmp(regClass.dataTypeString, "uint64")) // regClass.dataTypeString was null for TokenType in 'enum TokenType : ExpOperator' temp = PrintUInt64(value.data); else temp = PrintInt64(value.data); diff --git a/compiler/libec/src/pass2.ec b/compiler/libec/src/pass2.ec index f836a5f..b8b1ad9 100644 --- a/compiler/libec/src/pass2.ec +++ b/compiler/libec/src/pass2.ec @@ -3197,9 +3197,12 @@ static void ProcessExpression(Expression exp) if(!e.next && exp.usage.usageGet) e.usage.usageGet = true; ProcessExpression(e); } - if(exp.usage.usageGet) - exp.cond.elseExp.usage.usageGet = true; - ProcessExpression(exp.cond.elseExp); + if(exp.cond.elseExp) + { + if(exp.usage.usageGet) + exp.cond.elseExp.usage.usageGet = true; + ProcessExpression(exp.cond.elseExp); + } break; } case classExp: diff --git a/compiler/libec/src/pass3.ec b/compiler/libec/src/pass3.ec index 978888f..d5d3e0e 100644 --- a/compiler/libec/src/pass3.ec +++ b/compiler/libec/src/pass3.ec @@ -674,7 +674,8 @@ static void InstDeclPassExpression(Expression exp) InstDeclPassExpression(exp.cond.cond); for(e = exp.cond.exp->first; e; e = e.next) InstDeclPassExpression(e); - InstDeclPassExpression(exp.cond.elseExp); + if(exp.cond.elseExp) + InstDeclPassExpression(exp.cond.elseExp); break; } case extensionCompoundExp: -- 1.8.3.1