Skip to content

Commit

Permalink
fix CorruptInputError index error, #1
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Nov 2, 2023
1 parent 66abdc7 commit ca9c310
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions base64_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ func decode(enc *Encoding, dst, src []byte) (int, error) {
// decoded by SIMD
remain = srcLen - remain
src = src[remain:]
remain = (remain / 4) * 3
dst = dst[remain:]
dstStart := (remain / 4) * 3
dst = dst[dstStart:]
n, err := decodeGeneric(enc, dst, src)
return n + remain, err
if cerr, ok := err.(CorruptInputError); ok {
return n + dstStart, CorruptInputError(int(cerr) + remain)
}
return n + dstStart, err
}
}
return decodeGeneric(enc, dst, src)
Expand Down

0 comments on commit ca9c310

Please sign in to comment.