compiler/libec: Null checks
authorJerome St-Louis <jerome@ecere.com>
Tue, 16 Jun 2015 08:23:42 +0000 (04:23 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 15 Oct 2015 00:19:49 +0000 (20:19 -0400)
compiler/libec/src/pass0.ec
compiler/libec/src/pass1.ec
compiler/libec/src/pass2.ec
compiler/libec/src/pass3.ec

index 3a18141..1496fe8 100644 (file)
@@ -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;
 
index 0370d4a..7c0f957 100644 (file)
@@ -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);
index f836a5f..b8b1ad9 100644 (file)
@@ -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:
index 978888f..d5d3e0e 100644 (file)
@@ -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: