Skip to content

Commit

Permalink
Return useful info and just log error when replay is corrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
icza committed Mar 23, 2023
1 parent adea5d3 commit fd06ef4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/screp/screp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

const (
appName = "screp"
appVersion = "v1.11.0"
appVersion = "v1.11.1"
appAuthor = "Andras Belicza"
appHome = "https://github.com/icza/screp"
)
Expand Down
2 changes: 1 addition & 1 deletion repparser/repdecoder/modern.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var knownModernSectionIDSizeHints = map[int32]int32{
func (d *modernDecoder) Section(size int32) (result []byte, sectionID int32, err error) {
if d.sectionsCounter > 5 {
// These are the sections added in modern replays.
if sectionID, err = d.readInt32(); err != nil { // This is the StrID of the section, not checking it
if sectionID, err = d.readInt32(); err != nil { // This is the StrID of the section
return
}
var rawSize int32
Expand Down
7 changes: 6 additions & 1 deletion repparser/repparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import (

const (
// Version is a Semver2 compatible version of the parser.
Version = "v1.11.0"
Version = "v1.11.1"
)

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

Expand Down

0 comments on commit fd06ef4

Please sign in to comment.