## Coverage Report

#### Created: 2025-03-01 02:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /libfido2/src/types.c

    Line
    Count
    Source
    1
    /*
    2
     * Copyright (c) 2018-2022 Yubico AB. All rights reserved.
    3
     * Use of this source code is governed by a BSD-style
    4
     * license that can be found in the LICENSE file.
    5
     * SPDX-License-Identifier: BSD-2-Clause
    6
     */
    7
    8
    #include "fido.h"
    9
    10
    void
    11
    fido_str_array_free(fido_str_array_t *sa)
    12
    2.21M
    {
    13
    3.15M
            for (size_t i = 0; i < sa->len; i++)
    14
    942k
                    free(sa->ptr[i]);
    15
    16
    2.21M
            free(sa->ptr);
    17
    2.21M
            sa->ptr = NULL;
    18
    2.21M
            sa->len = 0;
    19
    2.21M
    }
    20
    21
    void
    22
    fido_opt_array_free(fido_opt_array_t *oa)
    23
    732k
    {
    24
    1.22M
            for (size_t i = 0; i < oa->len; i++)
    25
    492k
                    free(oa->name[i]);
    26
    27
    732k
            free(oa->name);
    28
    732k
            free(oa->value);
    29
    732k
            oa->name = NULL;
    30
    732k
            oa->value = NULL;
    31
    732k
            oa->len = 0;
    32
    732k
    }
    33
    34
    void
    35
    fido_byte_array_free(fido_byte_array_t *ba)
    36
    732k
    {
    37
    732k
            free(ba->ptr);
    38
    39
    732k
            ba->ptr = NULL;
    40
    732k
            ba->len = 0;
    41
    732k
    }
    42
    43
    void
    44
    fido_algo_free(fido_algo_t *a)
    45
    131k
    {
    46
    131k
            free(a->type);
    47
    131k
            a->type = NULL;
    48
    131k
            a->cose = 0;
    49
    131k
    }
    50
    51
    void
    52
    fido_algo_array_free(fido_algo_array_t *aa)
    53
    732k
    {
    54
    861k
            for (size_t i = 0; i < aa->len; i++)
    55
    129k
                    fido_algo_free(&aa->ptr[i]);
    56
    57
    732k
            free(aa->ptr);
    58
    732k
            aa->ptr = NULL;
    59
    732k
            aa->len = 0;
    60
    732k
    }
    61
    62
    void
    63
    fido_cert_array_free(fido_cert_array_t *ca)
    64
    732k
    {
    65
    744k
            for (size_t i = 0; i < ca->len; i++)
    66
    12.2k
                    free(ca->name[i]);
    67
    68
    732k
            free(ca->name);
    69
    732k
            free(ca->value);
    70
    732k
            ca->name = NULL;
    71
    732k
            ca->value = NULL;
    72
    732k
            ca->len = 0;
    73
    732k
    }
    74
    75
    int
    76
    fido_str_array_pack(fido_str_array_t *sa, const char * const *v, size_t n)
    77
    14.4k
    {
    78
    14.4k
            if ((sa->ptr = calloc(n, sizeof(char *))) == NULL) {
    79
    13
                    fido_log_debug("%s: calloc", __func__);
    80
    13
                    return -1;
    81
    13
            }
    82
    400k
            for (size_t i = 0; i < n; i++) {
    83
    387k
                    if ((sa->ptr[i] = strdup(v[i])) == NULL) {
    84
    1.08k
                            fido_log_debug("%s: strdup", __func__);
    85
    1.08k
                            return -1;
    86
    1.08k
                    }
    87
    386k
                    sa->len++;
    88
    386k
            }
    89
    90
    13.3k
            return 0;
    91
    14.3k
    }