Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit eff62aa

Browse files
committed
Make sure we copy the syncMarker when reading it
Otherwise, the syncMarker will point to the reusable array that we use for reading.
1 parent 940cab7 commit eff62aa

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

sequencefile/header.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ func (r *Reader) ReadHeader() error {
9797
}
9898

9999
r.Header.SyncMarker = string(marker)
100-
r.syncMarkerBytes = marker
100+
r.syncMarkerBytes = make([]byte, SyncSize)
101+
copy(r.syncMarkerBytes, marker)
101102

102103
return nil
103104
}

sequencefile/reader.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,11 @@ func (r *Reader) checkSyncAndScan(readValues bool) bool {
149149

150150
// If we never read the Header, infer the sync marker from the first time we
151151
// see it.
152-
if r.syncMarkerBytes == nil {
153-
r.syncMarkerBytes = b
152+
if r.syncMarkerBytes == []byte(nil) {
153+
r.syncMarkerBytes = make([]byte, SyncSize)
154+
copy(r.syncMarkerBytes, b)
154155
} else if !bytes.Equal(b, r.syncMarkerBytes) {
155-
r.close(fmt.Errorf("Invalid sync marker: %x", b))
156+
r.close(fmt.Errorf("Invalid sync marker: %x vs %x", b, r.syncMarkerBytes))
156157
return false
157158
}
158159

0 commit comments

Comments
 (0)