Skip to content

Commit 597b9ab

Browse files
authored
Fix an invalid mutation with a tag section (#2665)
Fixes an oss-fuzz test case that cropped up today
1 parent 3adfdbd commit 597b9ab

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

crates/wasm-mutate/src/mutators/add_function.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ impl Mutator for AddFunctionMutator {
106106
added_func = true;
107107
}
108108

109-
if !added_code
110-
&& sec_id >= wasm_encoder::SectionId::Code as u8
111-
&& sec_id != wasm_encoder::SectionId::DataCount as u8
112-
{
109+
if !added_code && sec_id == wasm_encoder::SectionId::Data as u8 {
113110
module.section(&code_sec_enc);
114111
added_code = true;
115112
}
@@ -188,4 +185,24 @@ mod tests {
188185
"#,
189186
);
190187
}
188+
189+
#[test]
190+
fn test_add_function_before_tag() {
191+
crate::mutators::match_mutation(
192+
r#"
193+
(module
194+
(type (;0;) (func))
195+
(tag (;0;) (type 0))
196+
)
197+
"#,
198+
AddFunctionMutator,
199+
r#"
200+
(module
201+
(type (;0;) (func))
202+
(tag (;0;) (type 0))
203+
(func (;0;) (type 0))
204+
)
205+
"#,
206+
);
207+
}
191208
}

0 commit comments

Comments
 (0)