]> Cypherpunks repositories - gostls13.git/commitdiff
gc: abort if given an unknown debug (-d) flag
authorAustin Clements <austin@google.com>
Tue, 4 Nov 2014 14:43:37 +0000 (09:43 -0500)
committerAustin Clements <austin@google.com>
Tue, 4 Nov 2014 14:43:37 +0000 (09:43 -0500)
The check for unknown command line debug flags in gc was
incorrect: the loop over debugtab terminates when it reaches a
nil entry, but it was only reporting an error if the parser
had passed the last entry of debugtab (which it never did).
Fix this by reporting the usage error if the loop reaches a
nil entry.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/166110043

src/cmd/gc/lex.c

index 2303b442cd5659cba7377a38535977437689a923..523ba37aa7b1ed1d99d477bca5a0aa6407436ac8 100644 (file)
@@ -344,8 +344,8 @@ main(int argc, char *argv[])
                                        break;
                                }
                        }
-                       if(j == nelem(debugtab))
-                               fatal("unknown debug information -d '%s'\n", f[i]);
+                       if(debugtab[j].name == nil)
+                               sysfatal("unknown debug information -d '%s'\n", f[i]);
                }
        }