Skip to content

Commit

Permalink
Merge pull request #3 from nlnwa/fix/nil-pointer-exception
Browse files Browse the repository at this point in the history
Fix nil pointer exception
  • Loading branch information
maeb authored Dec 13, 2023
2 parents e80544b + a3447c1 commit ddbc0b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions internal/warc/testdata/corrupt.warc.gz
Git LFS file not shown
5 changes: 4 additions & 1 deletion internal/warc/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ func IsValid(file, tmpDir string) (bool, error) {
return validation.Valid(), nil
}
if err != nil {
*validation = append(*validation, err)
if wr != nil {
defer wr.Close()
}
return false, nil
}
func() {
defer wr.Close()
Expand Down
9 changes: 7 additions & 2 deletions internal/warc/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import (
)

const (
validWarcFile = "testdata/valid.warc.gz"
invalidWarcFile = "testdata/invalid.warc.gz"
validWarcFile = "testdata/valid.warc.gz"
invalidWarcFile = "testdata/invalid.warc.gz"
corruptedWarcFile = "testdata/corrupt.warc.gz"
)

func TestMain(m *testing.M) {
Expand All @@ -42,6 +43,10 @@ func TestIsValid(t *testing.T) {
file: invalidWarcFile,
isValid: false,
},
{
file: corruptedWarcFile,
isValid: false,
},
}

for _, test := range tests {
Expand Down

0 comments on commit ddbc0b6

Please sign in to comment.