internal/ops: avoid some bounds checks in decode

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2022-07-02 15:37:09 +03:00
committed by Elias Naur
parent f8efc9c2a6
commit e7dd180447
2 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -163,9 +163,10 @@ const (
)
func (op *ClipOp) Decode(data []byte) {
if OpType(data[0]) != TypeClip {
if len(data) < TypeClipLen || OpType(data[0]) != TypeClip {
panic("invalid op")
}
data = data[:TypeClipLen]
bo := binary.LittleEndian
r := image.Rectangle{
Min: image.Point{