Skip to content

Commit

Permalink
Fix NewDataFromBits
Browse files Browse the repository at this point in the history
The Bytes field needed to be allocated before use.
  • Loading branch information
bemasher committed Oct 18, 2014
1 parent 9994aaa commit ed47c5c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func NewDataFromBytes(data []byte) (d Data) {

func NewDataFromBits(data string) (d Data) {
d.Bits = data
d.Bytes = make([]byte, len(data)>>3+1)
for idx := 0; idx < len(data); idx += 8 {
b, _ := strconv.ParseUint(d.Bits[idx:idx+8], 2, 8)
d.Bytes[idx>>3] = uint8(b)
Expand Down

0 comments on commit ed47c5c

Please sign in to comment.