diff options
author | Dominik Honnef <dominik@honnef.co> | 2016-03-26 08:48:56 +0100 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2016-09-13 12:21:10 +0000 |
commit | 5ffc3249d341c947aa65178abbf2253ed49c9e03 (patch) | |
tree | 7642c8c2603facd9dac887280287c56c5c776fd2 /present | |
parent | 86ad1193da6aba71355e71191641b9cfb26daa67 (diff) | |
download | golang-x-tools-5ffc3249d341c947aa65178abbf2253ed49c9e03.tar.gz |
present: dont crash if address searched backwards
For /start/,/end/, the /end/ address can wrap around and match somewhere
before /start/. Handle this case without crashing.
Fixes golang/go#7163.
Change-Id: I6fc3b5048e88728c9403a1d1e284ea8ada567a1e
Reviewed-on: https://go-review.googlesource.com/21182
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'present')
-rw-r--r-- | present/code.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/present/code.go b/present/code.go index edf2ee421..681aaa005 100644 --- a/present/code.go +++ b/present/code.go @@ -89,6 +89,11 @@ func parseCode(ctx *Context, sourceFile string, sourceLine int, cmd string) (Ele if err != nil { return nil, fmt.Errorf("%s:%d: %v", sourceFile, sourceLine, err) } + if lo > hi { + // The search in addrToByteRange can wrap around so we might + // end up with the range ending before its starting point + hi, lo = lo, hi + } // Acme pattern matches can stop mid-line, // so run to end of line in both directions if not at line start/end. |