From: Austin Clements Date: Tue, 4 Nov 2014 14:43:37 +0000 (-0500) Subject: gc: abort if given an unknown debug (-d) flag X-Git-Tag: go1.4rc1~50 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=516d9ef53b656aa5e6eebdc2c09e8d257b13e033;p=gostls13.git gc: abort if given an unknown debug (-d) flag 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 --- diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c index 2303b442cd..523ba37aa7 100644 --- a/src/cmd/gc/lex.c +++ b/src/cmd/gc/lex.c @@ -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]); } }