]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: more graceful handling of invalid fields in widstruct.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 7 Oct 2012 19:46:10 +0000 (21:46 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 7 Oct 2012 19:46:10 +0000 (21:46 +0200)
The protection against segfaults does not completely solve
crashes and breaks test/fixedbugs/bug365.go

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6615058

src/cmd/gc/align.c
src/cmd/gc/go.h

index d9d4df316fd384f9a1764a31c31a9bc07fa0ae79..118af7e16220b902579e16f1f75c45a0940e4e7a 100644 (file)
@@ -54,8 +54,11 @@ widstruct(Type *errtype, Type *t, vlong o, int flag)
        for(f=t->type; f!=T; f=f->down) {
                if(f->etype != TFIELD)
                        fatal("widstruct: not TFIELD: %lT", f);
-               if(f->type == T)
-                       break;
+               if(f->type == T) {
+                       // broken field, just skip it so that other valid fields
+                       // get a width.
+                       continue;
+               }
                dowidth(f->type);
                if(f->type->align > maxalign)
                        maxalign = f->type->align;
index f6bf8ef8c2900ad947bc927571f6719ad3f68093..eb2345d6da3543e56cb2e562c9a9c4e9c58ad0fc 100644 (file)
@@ -146,7 +146,7 @@ struct      Type
        uchar   copyany;
        uchar   local;          // created in this file
        uchar   deferwidth;
-       uchar   broke;
+       uchar   broke;          // broken type definition.
        uchar   isddd;          // TFIELD is ... argument
        uchar   align;