Skip to content

Commit fd06ef4

Browse files
committed
Return useful info and just log error when replay is corrupted
1 parent adea5d3 commit fd06ef4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

cmd/screp/screp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
const (
2626
appName = "screp"
27-
appVersion = "v1.11.0"
27+
appVersion = "v1.11.1"
2828
appAuthor = "Andras Belicza"
2929
appHome = "https://github.com/icza/screp"
3030
)

repparser/repdecoder/modern.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var knownModernSectionIDSizeHints = map[int32]int32{
2828
func (d *modernDecoder) Section(size int32) (result []byte, sectionID int32, err error) {
2929
if d.sectionsCounter > 5 {
3030
// These are the sections added in modern replays.
31-
if sectionID, err = d.readInt32(); err != nil { // This is the StrID of the section, not checking it
31+
if sectionID, err = d.readInt32(); err != nil { // This is the StrID of the section
3232
return
3333
}
3434
var rawSize int32

repparser/repparser.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import (
6060

6161
const (
6262
// Version is a Semver2 compatible version of the parser.
63-
Version = "v1.11.0"
63+
Version = "v1.11.1"
6464
)
6565

6666
var (
@@ -247,6 +247,11 @@ func parse(dec repdecoder.Decoder, cfg Config) (*rep.Replay, error) {
247247
if err == io.EOF {
248248
break // New sections with StrID are optional
249249
}
250+
if sectionCounter >= len(Sections) {
251+
// If we got "enough" info, just log the error:
252+
log.Printf("Warning: Decoder.Section() error: %v", err)
253+
break
254+
}
250255
return nil, fmt.Errorf("Decoder.Section() error: %w", err)
251256
}
252257

0 commit comments

Comments
 (0)