Coverage Report

Created: 2025-10-10 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wasm3/platforms/app_fuzz/fuzzer.c
Line
Count
Source
1
//
2
//  Wasm3 - high performance WebAssembly interpreter written in C.
3
//
4
//  Copyright © 2019 Steven Massey, Volodymyr Shymanskyy.
5
//  All rights reserved.
6
//
7
8
#include <stdint.h>
9
#include <stddef.h>
10
11
#include "wasm3.h"
12
13
#define FATAL(...) __builtin_trap()
14
15
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
16
174
{
17
174
    M3Result result = m3Err_none;
18
19
174
    if (size < 8 || size > 256*1024) {
20
5
        return 0;
21
5
    }
22
23
169
    IM3Environment env = m3_NewEnvironment ();
24
169
    if (env) {
25
169
        IM3Runtime runtime = m3_NewRuntime (env, 128, NULL);
26
169
        if (runtime) {
27
169
            IM3Module module = NULL;
28
169
            result = m3_ParseModule (env, &module, data, size);
29
169
            if (module) {
30
93
                result = m3_LoadModule (runtime, module);
31
93
                if (result == 0) {
32
58
                    IM3Function f = NULL;
33
58
                    result = m3_FindFunction (&f, runtime, "fib");
34
                    /* TODO:
35
                    if (f) {
36
                        m3_CallV (f, 10);
37
                    }*/
38
58
                } else {
39
35
                    m3_FreeModule (module);
40
35
                }
41
93
            }
42
43
169
            m3_FreeRuntime(runtime);
44
169
        }
45
169
        m3_FreeEnvironment(env);
46
169
    }
47
48
169
    return 0;
49
174
}