Browse Source

Fix some offset calculation bugs

Evan Huus 12 years ago
parent
commit
1c4240b9cf
2 changed files with 2 additions and 2 deletions
  1. 2 0
      real_decoder.go
  2. 0 2
      real_encoder.go

+ 2 - 0
real_decoder.go

@@ -77,6 +77,7 @@ func (rd *realDecoder) getString() (*string, error) {
 	default:
 		tmp := new(string)
 		*tmp = string(rd.raw[rd.off : rd.off+n])
+		rd.off += n
 		return tmp, nil
 	}
 }
@@ -102,6 +103,7 @@ func (rd *realDecoder) getBytes() (*[]byte, error) {
 		return nil, DecodingError{}
 	default:
 		tmp := rd.raw[rd.off : rd.off+n]
+		rd.off += n
 		return &tmp, nil
 	}
 }

+ 0 - 2
real_encoder.go

@@ -38,7 +38,6 @@ func (re *realEncoder) putString(in *string) {
 		return
 	}
 	re.putInt16(int16(len(*in)))
-	re.off += 2
 	copy(re.raw[re.off:], *in)
 	re.off += len(*in)
 }
@@ -49,7 +48,6 @@ func (re *realEncoder) putBytes(in *[]byte) {
 		return
 	}
 	re.putInt32(int32(len(*in)))
-	re.off += 4
 	copy(re.raw[re.off:], *in)
 	re.off += len(*in)
 }