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>
diff --git a/present/code.go b/present/code.go
index edf2ee4..681aaa0 100644
--- a/present/code.go
+++ b/present/code.go
@@ -89,6 +89,11 @@
 	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.