From: wiml Date: Fri, 20 Sep 2002 17:25:21 +0000 (+0000) Subject: Test pointer for NULL *before* dereferencing it, not immediately after (fix crash... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=ab0c0d4209a086795b25e9d9a47213d0bb89708d;p=fw%2Fsdcc Test pointer for NULL *before* dereferencing it, not immediately after (fix crash reported by Jesus Calvino-Fraga) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2105 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 7c94daff..aab641b6 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -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 */