We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6c57bdc commit 813cd6cCopy full SHA for 813cd6c
1 file changed
crates/wasmparser/src/readers/core/reloc.rs
@@ -302,3 +302,21 @@ impl<'a> FromReader<'a> for RelocationEntry {
302
})
303
}
304
305
+
306
+// Assert that `relocation_range` does not wrap when `offset + extent` exceeds `usize::MAX`.
307
+#[test]
308
+fn relocation_range_does_not_overflow() {
309
+ let entry = RelocationEntry {
310
+ ty: RelocationType::FunctionIndexLeb,
311
+ offset: 0xFFFF_FFFC,
312
+ index: 0,
313
+ addend: 0,
314
+ };
315
+ if cfg!(target_pointer_width = "32") {
316
+ assert!(entry.relocation_range().is_err());
317
+ } else {
318
+ let range = entry.relocation_range().unwrap();
319
+ assert_eq!(range.start, 0xFFFF_FFFC);
320
+ assert_eq!(range.end, 0xFFFF_FFFC + 5);
321
+ }
322
+}
0 commit comments