mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
lang: reject 0-length arrays
This commit is contained in:
1 parent
4a2f570d56
commit
e930d66897
1 file changed
+3
-1
+3
-1
@@ -1186,8 +1186,10 @@ swtch:
|
|||||||
if err := q.tcheckExpr(aLen, 0); err != nil {
|
if err := q.tcheckExpr(aLen, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if aLen.ConstValue() == nil {
|
if cv := aLen.ConstValue(); cv == nil {
|
||||||
return fmt.Errorf("check: %q is not constant", aLen.Str(q.tm))
|
return fmt.Errorf("check: %q is not constant", aLen.Str(q.tm))
|
||||||
|
} else if cv.Sign() <= 0 {
|
||||||
|
return fmt.Errorf("check: array length %q is not positive", aLen.Str(q.tm))
|
||||||
}
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user