Skip to content

Commit

Permalink
Catch IO advancement errors as well
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Jan 12, 2024
1 parent c645ff4 commit e8ab61f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions v5/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package jsonpatch
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"reflect"
)

Expand Down Expand Up @@ -183,6 +185,12 @@ func doMergePatch(docData, patchData []byte, mergeMerge bool) ([]byte, error) {
}

func isSyntaxError(err error) bool {
if errors.Is(err, io.EOF) {
return true
}
if errors.Is(err, io.ErrUnexpectedEOF) {
return true
}
if _, ok := err.(*json.SyntaxError); ok {
return true
}
Expand Down

0 comments on commit e8ab61f

Please sign in to comment.