|
| 1 | +;; Unsigned LEB128 can have non-minimal length |
| 2 | +(module binary |
| 3 | + "\00asm" "\01\00\00\00" |
| 4 | + "\05\07\02" ;; Memory section with 2 entries |
| 5 | + "\00\82\00" ;; no max, minimum 2 |
| 6 | + "\00\82\00" ;; no max, minimum 2 |
| 7 | +) |
| 8 | +(module binary |
| 9 | + "\00asm" "\01\00\00\00" |
| 10 | + "\05\13\03" ;; Memory section with 3 entries |
| 11 | + "\00\83\80\80\80\00" ;; no max, minimum 3 |
| 12 | + "\00\84\80\80\80\00" ;; no max, minimum 4 |
| 13 | + "\00\85\80\80\80\00" ;; no max, minimum 5 |
| 14 | +) |
| 15 | + |
| 16 | +(module binary |
| 17 | + "\00asm" "\01\00\00\00" |
| 18 | + "\05\05\02" ;; Memory section with 2 entries |
| 19 | + "\00\00" ;; no max, minimum 0 |
| 20 | + "\00\00" ;; no max, minimum 0 |
| 21 | + "\0b\06\01" ;; Data section with 1 entry |
| 22 | + "\00" ;; Memory index 0 |
| 23 | + "\41\00\0b\00" ;; (i32.const 0) with contents "" |
| 24 | +) |
| 25 | + |
| 26 | +(module binary |
| 27 | + "\00asm" "\01\00\00\00" |
| 28 | + "\05\05\02" ;; Memory section with 2 entries |
| 29 | + "\00\00" ;; no max, minimum 0 |
| 30 | + "\00\01" ;; no max, minimum 1 |
| 31 | + "\0b\07\01" ;; Data section with 1 entry |
| 32 | + "\02\01" ;; Memory index 1 |
| 33 | + "\41\00\0b\00" ;; (i32.const 0) with contents "" |
| 34 | +) |
| 35 | + |
| 36 | +(module binary |
| 37 | + "\00asm" "\01\00\00\00" |
| 38 | + "\05\05\02" ;; Memory section with 2 entries |
| 39 | + "\00\00" ;; no max, minimum 0 |
| 40 | + "\00\01" ;; no max, minimum 1 |
| 41 | + "\0b\0a\01" ;; Data section with 1 entry |
| 42 | + "\02\81\80\80\00" ;; Memory index 1 |
| 43 | + "\41\00\0b\00" ;; (i32.const 0) with contents "" |
| 44 | +) |
| 45 | + |
| 46 | +;; Unsigned LEB128 must not be overlong |
| 47 | +(assert_malformed |
| 48 | + (module binary |
| 49 | + "\00asm" "\01\00\00\00" |
| 50 | + "\05\10\02" ;; Memory section with 2 entries |
| 51 | + "\00\01" ;; no max, minimum 1 |
| 52 | + "\00\82\80\80\80\80\80\80\80\80\80\80\00" ;; no max, minimum 2 with one byte too many |
| 53 | + ) |
| 54 | + "integer representation too long" |
| 55 | +) |
| 56 | + |
| 57 | +;; 2 memories declared, 1 given |
| 58 | +(assert_malformed |
| 59 | + (module binary |
| 60 | + "\00asm" "\01\00\00\00" |
| 61 | + "\05\03\02" ;; memory section with inconsistent count (1 declared, 0 given) |
| 62 | + "\00\00" ;; memory 0 (missed) |
| 63 | + ;; "\00\00" ;; memory 1 (missing) |
| 64 | + ) |
| 65 | + "unexpected end of section or function" |
| 66 | +) |
| 67 | + |
0 commit comments