]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix nil pointer dereferences.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 26 Mar 2013 07:20:10 +0000 (08:20 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 26 Mar 2013 07:20:10 +0000 (08:20 +0100)
Fixes #5119.

R=golang-dev, dvyukov, dave, rsc
CC=golang-dev
https://golang.org/cl/7838050

src/cmd/gc/dcl.c
src/cmd/gc/subr.c

index 429f212e7fc501d8d278842ae20c8224128ece7f..d3759efde3f1677593e473aed5836025bd8a8f0f 100644 (file)
@@ -1339,6 +1339,8 @@ addmethod(Sym *sf, Type *t, int local, int nointerface)
        f = methtype(pa, 1);
        if(f == T) {
                t = pa;
+               if(t == T) // rely on typecheck having complained before
+                       return;
                if(t != T) {
                        if(isptr[t->etype]) {
                                if(t->sym != S) {
@@ -1347,10 +1349,8 @@ addmethod(Sym *sf, Type *t, int local, int nointerface)
                                }
                                t = t->type;
                        }
-               }
-               if(t->broke) // rely on typecheck having complained before
-                       return;
-               if(t != T) {
+                       if(t->broke) // rely on typecheck having complained before
+                               return;
                        if(t->sym == S) {
                                yyerror("invalid receiver type %T (%T is an unnamed type)", pa, t);
                                return;
index de3b92d13c552a5ba6ca6f1b21fc2d1c322a9987..255f4c73adfb593c6159fc4774c549520bd40c2a 100644 (file)
@@ -714,6 +714,12 @@ methcmp(const void *va, const void *vb)
        
        a = *(Type**)va;
        b = *(Type**)vb;
+       if(a->sym == S && b->sym == S)
+               return 0;
+       if(a->sym == S)
+               return -1;
+       if(b->sym == S)
+               return 1;
        i = strcmp(a->sym->name, b->sym->name);
        if(i != 0)
                return i;
@@ -1393,7 +1399,7 @@ assignconv(Node *n, Type *t, char *context)
        Node *r, *old;
        char *why;
        
-       if(n == N || n->type == T)
+       if(n == N || n->type == T || n->type->broke)
                return n;
 
        old = n;