From 30e48093fcc9c5a4390c264a285dc68409f2e84e Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 24 May 2018 11:44:16 +1000 Subject: [PATCH] Bounds check the components of a s[i:j] expr --- lang/check/bounds.go | 14 ++++++++++++++ std/gif/decode_gif.wuffs | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lang/check/bounds.go b/lang/check/bounds.go index d21de527..e3ace9de 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -877,8 +877,22 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int, case t.IDColon: lhs := n.LHS().Expr() + if _, _, err := q.bcheckExpr(lhs, depth); err != nil { + return nil, nil, err + } mhs := n.MHS().Expr() + if mhs != nil { + if _, _, err := q.bcheckExpr(mhs, depth); err != nil { + return nil, nil, err + } + } rhs := n.RHS().Expr() + if rhs != nil { + if _, _, err := q.bcheckExpr(rhs, depth); err != nil { + return nil, nil, err + } + } + if mhs == nil && rhs == nil { return nil, nil, nil } diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 0022e89c..574919db 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -432,8 +432,7 @@ pri func decoder.decode_id_part1?(ib ptr base.image_buffer, dst base.io_writer, } // TODO: have a builtin btoi or "b as base.u32"? - // TODO: p's type should be base.u32[..1] - var p base.u32 = 0 + var p base.u32[..1] = 0 if this.have_lct { p = 1 }