Coverage Report

Created: 2025-07-18 06:11

/src/selinux/libsepol/src/constraint.c
Line
Count
Source (jump to first uncovered line)
1
/* Authors: Jason Tang <jtang@tresys.com>
2
 *
3
 * Copyright (C) 2005 Tresys Technology, LLC
4
 *
5
 *  This library is free software; you can redistribute it and/or
6
 *  modify it under the terms of the GNU Lesser General Public
7
 *  License as published by the Free Software Foundation; either
8
 *  version 2.1 of the License, or (at your option) any later version.
9
 *
10
 *  This library is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 *  Lesser General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU Lesser General Public
16
 *  License along with this library; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
#include <sepol/policydb/policydb.h>
21
#include <sepol/policydb/constraint.h>
22
#include <sepol/policydb/expand.h>
23
#include <sepol/policydb/flask_types.h>
24
25
#include <assert.h>
26
#include <stdlib.h>
27
28
int constraint_expr_init(constraint_expr_t * expr)
29
12.0M
{
30
12.0M
  memset(expr, 0, sizeof(*expr));
31
12.0M
  ebitmap_init(&expr->names);
32
12.0M
  if ((expr->type_names = malloc(sizeof(*expr->type_names))) == NULL) {
33
0
    return -1;
34
0
  }
35
12.0M
  type_set_init(expr->type_names);
36
12.0M
  return 0;
37
12.0M
}
38
39
void constraint_expr_destroy(constraint_expr_t * expr)
40
2.06M
{
41
2.06M
  constraint_expr_t *next;
42
43
14.1M
  while (expr != NULL) {
44
12.0M
    next = expr->next;
45
12.0M
    ebitmap_destroy(&expr->names);
46
12.0M
    type_set_destroy(expr->type_names);
47
12.0M
    free(expr->type_names);
48
12.0M
    free(expr);
49
12.0M
    expr = next;
50
12.0M
  }
51
2.06M
}