Coverage Report

Created: 2026-06-25 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mpv/fuzzers/fuzzer_options_parser.c
Line
Count
Source
1
/*
2
 * This file is part of mpv.
3
 *
4
 * mpv is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * mpv is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with mpv.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
#include <stdint.h>
19
#include <stdlib.h>
20
#include <ctype.h>
21
22
#include "common.h"
23
24
int mpv_initialize_opts(mpv_handle *ctx, char **options);
25
26
422
#define MAX_INPUT_SIZE 2048
27
38.7k
#define MAX_OPTS_NUM 10000
28
29
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
30
422
{
31
422
    char buff[MAX_INPUT_SIZE + 2];
32
33
422
    if (!size || size > MAX_INPUT_SIZE)
34
3
        return 0;
35
36
419
    memcpy(buff, data, size);
37
419
    buff[size] = '\0';
38
419
    buff[size + 1] = '\0';
39
40
419
    char *opts[MAX_OPTS_NUM + 1];
41
419
    char *opt = buff;
42
419
    int count = 0;
43
39.1k
    while (*opt && count < MAX_OPTS_NUM) {
44
38.7k
        opts[count] = opt;
45
46
660k
        while (*opt && !isspace(*opt))
47
621k
            opt++;
48
49
38.7k
        *opt = '\0';
50
38.7k
        opt++;
51
52
39.4k
        while (*opt && isspace(*opt))
53
783
            opt++;
54
55
38.7k
        count++;
56
38.7k
    }
57
419
    opts[count] = NULL;
58
59
419
    set_fontconfig_sysroot();
60
61
419
    mpv_handle *ctx = mpv_create();
62
419
    if (!ctx)
63
0
        exit(1);
64
65
419
    mpv_initialize_opts(ctx, opts);
66
67
419
    mpv_terminate_destroy(ctx);
68
69
419
    return 0;
70
419
}