Browse Source

internal/deephash: reset scratch before appending to it

Oops. In practice this doesn't matter, but it's still wrong.

Signed-off-by: Josh Bleecher Snyder <[email protected]>
Josh Bleecher Snyder 4 years ago
parent
commit
b340beff8e
1 changed files with 1 additions and 1 deletions
  1. 1 1
      internal/deephash/deephash.go

+ 1 - 1
internal/deephash/deephash.go

@@ -156,7 +156,7 @@ func print(w *bufio.Writer, v reflect.Value, visited map[uintptr]bool, scratch [
 	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
 		fmt.Fprintf(w, "%v", v.Int())
 	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
-		scratch = strconv.AppendUint(scratch, v.Uint(), 10)
+		scratch = strconv.AppendUint(scratch[:0], v.Uint(), 10)
 		w.Write(scratch)
 	case reflect.Float32, reflect.Float64:
 		fmt.Fprintf(w, "%v", v.Float())