aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2015-05-20 13:26:02 -0700
committerRob Pike <r@golang.org>2015-05-20 20:53:14 +0000
commit8401b19e7e6bf60d66b2d71cd3fa2215c4649d31 (patch)
tree9247e6b21a3bddc05609c3ebc90ceeb6890338b2 /src
parent197aa9e64ddcd1cdcb5f4843413da935a954d9f3 (diff)
downloadgo-8401b19e7e6bf60d66b2d71cd3fa2215c4649d31.tar.xz
cmd/doc: fix handling of paths like ./fmt
An error in string slice offsets caused the loop to run forever if the first character in the argument was a period. Fixes #10833. Change-Id: Iefb6aac5cff8864fe93d08e2600cb07d82c6f6df Reviewed-on: https://go-review.googlesource.com/10285 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/doc/main.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/doc/main.go b/src/cmd/doc/main.go
index b3be2a975b..18dafc298c 100644
--- a/src/cmd/doc/main.go
+++ b/src/cmd/doc/main.go
@@ -132,11 +132,12 @@ func parseArgs() (*build.Package, string, string) {
// slash+1: if there's no slash, the value is -1 and start is 0; otherwise
// start is the byte after the slash.
for start := slash + 1; start < len(arg); start = period + 1 {
- period = start + strings.Index(arg[start:], ".")
+ period = strings.Index(arg[start:], ".")
symbol := ""
if period < 0 {
period = len(arg)
} else {
+ period += start
symbol = arg[period+1:]
}
// Have we identified a package already?