Coverage Report

Created: 2025-06-23 06:10

/src/fuzzing-headers/include/fuzzing/memory.hpp
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <stdio.h>
4
#include <optional>
5
#include <string>
6
7
namespace fuzzing {
8
namespace memory {
9
10
#ifndef FUZZING_HEADERS_NO_IMPL
11
#if ASAN == 1
12
extern "C" void *__asan_region_is_poisoned(const void *beg, size_t size);
13
#endif
14
15
#if MSAN == 1
16
extern "C" void __msan_check_mem_is_initialized(const volatile void *x, size_t size);
17
#endif
18
19
void memory_test_asan(const void* data, const size_t size)
20
0
{
21
0
    (void)data;
22
0
    (void)size;
23
24
#if ASAN == 1
25
    if ( __asan_region_is_poisoned(data, size) != NULL ) {
26
        abort();
27
    }
28
#endif
29
0
}
30
31
void memory_test_msan(const void* data, const size_t size)
32
0
{
33
0
    (void)data;
34
0
    (void)size;
35
36
#if MSAN == 1
37
    __msan_check_mem_is_initialized(data, size);
38
#endif
39
0
}
40
41
void memory_test(const void* data, const size_t size)
42
0
{
43
0
    memory_test_asan(data, size);
44
0
    memory_test_msan(data, size);
45
0
}
46
47
template <class T>
48
void memory_test(const T& t)
49
{
50
    (void)t;
51
}
52
53
template <>
54
void memory_test(const std::string& s)
55
0
{
56
0
    (void)s;
57
58
#if MSAN == 1
59
    memory_test(s.data(), s.size());
60
#endif
61
0
}
62
63
#endif
64
65
} /* namespace memory */
66
} /* namespace fuzzing */