aboutsummaryrefslogtreecommitdiff
path: root/bencode
diff options
context:
space:
mode:
Diffstat (limited to 'bencode')
-rw-r--r--bencode/bencode.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/bencode/bencode.go b/bencode/bencode.go
index 062e980..2c2bdfc 100644
--- a/bencode/bencode.go
+++ b/bencode/bencode.go
@@ -172,11 +172,9 @@ func (d *decodeState) unmarshalDict(v reflect.Value) {
}
}
}
- if ih := v.FieldByName("InfoHash"); ih.IsValid() {
- if infoEnd > infoOff {
- sum := sha1.Sum(d.data[infoOff:infoEnd])
- ih.SetBytes(sum[:])
- }
+ if ih := v.FieldByName("InfoHash"); ih.IsValid() && infoEnd > infoOff {
+ sum := sha1.Sum(d.data[infoOff:infoEnd])
+ ih.SetBytes(sum[:])
}
d.off++
}