[hackers] [scc] Fix eqtype() bug || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 10 Aug 2015 23:21:07 +0200 (CEST)

commit 1fd69c115bb5155d7dca44242d9c331d122786a4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Aug 10 23:15:53 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Aug 10 23:15:53 2015 +0200

    Fix eqtype() bug
    
    Number of elements in functions can be negative
    (the void case).

diff --git a/cc1/types.c b/cc1/types.c
index f3b6577..599378d 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -330,9 +330,11 @@ mktype(Type *tp, unsigned op, short nelem, Type *pars[])
 bool
 eqtype(Type *tp1, Type *tp2)
 {
- unsigned n;
+ int n;
         Type **p1, **p2;
 
+ if (!tp1 || !tp2)
+ return 0;
         if (tp1 == tp2)
                 return 1;
         if (tp1->op != tp2->op || tp1->n.elem != tp2->n.elem)
_AT_@ -345,7 +347,7 @@ eqtype(Type *tp1, Type *tp2)
         case STRUCT:
         case FTN:
                 p1 = tp1->pars, p2 = tp2->pars;
- for (n = tp1->n.elem; n != 0; --n) {
+ for (n = tp1->n.elem; n > 0; --n) {
                         if (!eqtype(*p1++, *p2++))
                                 return 0;
                 }
Received on Mon Aug 10 2015 - 23:21:07 CEST

This archive was generated by hypermail 2.3.0 : Mon Aug 10 2015 - 23:24:13 CEST