mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
internal/ops: avoid some bounds checks in decode
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
+2
-1
@@ -163,9 +163,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (op *ClipOp) Decode(data []byte) {
|
func (op *ClipOp) Decode(data []byte) {
|
||||||
if OpType(data[0]) != TypeClip {
|
if len(data) < TypeClipLen || OpType(data[0]) != TypeClip {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
|
data = data[:TypeClipLen]
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
r := image.Rectangle{
|
r := image.Rectangle{
|
||||||
Min: image.Point{
|
Min: image.Point{
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ func (r *Reader) Decode() (EncodedOp, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (op *opMacroDef) decode(data []byte) {
|
func (op *opMacroDef) decode(data []byte) {
|
||||||
if OpType(data[0]) != TypeMacro {
|
if len(data) < TypeMacroLen || OpType(data[0]) != TypeMacro {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
@@ -176,11 +176,11 @@ func (op *opMacroDef) decode(data []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *macroOp) decode(data []byte, refs []interface{}) {
|
func (m *macroOp) decode(data []byte, refs []interface{}) {
|
||||||
if OpType(data[0]) != TypeCall {
|
if len(data) < TypeCallLen || len(refs) < 1 || OpType(data[0]) != TypeCall {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
data = data[:TypeCallLen]
|
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
|
data = data[:TypeCallLen]
|
||||||
*m = macroOp{
|
*m = macroOp{
|
||||||
ops: refs[0].(*Ops),
|
ops: refs[0].(*Ops),
|
||||||
start: PC{
|
start: PC{
|
||||||
|
|||||||
Reference in New Issue
Block a user