mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 16:47:28 +01:00
Bounds check intermediate expressions.
When checking "(a + b) * 0", "a + b" might still overflow.
This commit is contained in:
1 parent
ebf3713555
commit
793eb043a4
4 files changed
+53
-35
No files matched your search
@@ -481,6 +481,16 @@ func (n *TypeExpr) IsRefined() bool {
|
||||
return t.Key(n.id0>>t.KeyShift) != t.KeyOpenBracket && (n.lhs != nil || n.mhs != nil)
|
||||
}
|
||||
|
||||
func (n *TypeExpr) Unrefined() *TypeExpr {
|
||||
if !n.IsRefined() {
|
||||
return n
|
||||
}
|
||||
o := *n
|
||||
o.lhs = nil
|
||||
o.mhs = nil
|
||||
return &o
|
||||
}
|
||||
|
||||
func NewTypeExpr(pkgOrDec t.ID, name t.ID, arrayLengthMin *Expr, max *Expr, inner *TypeExpr) *TypeExpr {
|
||||
return &TypeExpr{
|
||||
kind: KTypeExpr,
|
||||
|
||||
Reference in new issue
Block a user