summaryrefslogtreecommitdiff
path: root/fuzz/fuzz_targets/no-panic.rs
blob: 65efa6a561f07866e36ecc03a7498d215888396a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![no_main]
use libfuzzer_sys::fuzz_target;

use yaxpeax_arch::Decoder;

use std::fmt::Write;

fuzz_target!(|data: &[u8]| {

    let decoders = [
        yaxpeax_rx::InstDecoder::v1(),
        yaxpeax_rx::InstDecoder::v2(),
        yaxpeax_rx::InstDecoder::v3(),
    ];

    let mut rx_inst = yaxpeax_rx::Instruction::default();

    for decoder in decoders {
        let mut words = yaxpeax_arch::U8Reader::new(data);
        // test decoding, may be ok or not, but should not panic
        if let Ok(()) = decoder.decode_into(&mut rx_inst, &mut words) {
            write!(&mut String::new(), "{}", rx_inst).expect("formatting does not panic either");
        }
    }
});