check_precedence: fix a segfault
commite23238ea0e0280f2823cc9ecd10f965c094a71b0
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 1 Nov 2012 08:43:17 +0000 (1 11:43 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 1 Nov 2012 08:43:17 +0000 (1 11:43 +0300)
tree3a1794449584202111bbdedefaa0d42c8c6760d5
parent8bd353200209b6bfafeba31f27a74dc9447289bd
check_precedence: fix a segfault

This test should have been OK, but apparently there is a way to try make
this parse an expression struct which wasn't been initialized all the way.
What happened here is that I had a VALUE expression with the ->op set to
'!'.  In some ways, this fix is a hack, but in another way it is just
making the check more robust.

Here is the example program with triggered the bug.

enum {
       OST_FALSE = 0,
       OST_TRUE = (!OST_FALSE)
};

int test(void)
{
       int x = 0;
       if (OST_TRUE == x) {
       }
}

Reported-by: Pontus Fuchs <pontus.fuchs@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_precedence.c