Test pointer for NULL *before* dereferencing it, not immediately after (fix crash...
authorwiml <wiml@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 20 Sep 2002 17:25:21 +0000 (17:25 +0000)
committerwiml <wiml@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 20 Sep 2002 17:25:21 +0000 (17:25 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2105 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/mcs51/ralloc.c

index 7c94daff5926cd9abf98b1309670e22e29335b59..aab641b6e4a9a859722e2353574b0858cca2da0b 100644 (file)
@@ -2387,6 +2387,11 @@ packRegsForAccUse (iCode * ic)
     return;
 #endif
 
+  /* if the usage has only one operand then we can */
+  if (IC_LEFT (uic) == NULL ||
+      IC_RIGHT (uic) == NULL)
+    goto accuse;
+
   /* if the other operand uses the accumulator then we cannot */
   if ( (IC_LEFT(uic)->key == IC_RESULT(ic)->key &&
        operandUsesAcc(IC_RIGHT(uic))) ||
@@ -2394,11 +2399,6 @@ packRegsForAccUse (iCode * ic)
        operandUsesAcc(IC_LEFT(uic))) ) 
     return;
 
-  /* if the usage has only one operand then we can */
-  if (IC_LEFT (uic) == NULL ||
-      IC_RIGHT (uic) == NULL)
-    goto accuse;
-
   /* make sure this is on the left side if not commutative */
   /* except for '-', which has been written to be able to
      handle reversed operands */