Skip to content

Commit

Permalink
libsepol/cil: Update symtab nprim field when adding or removing datums
Browse files Browse the repository at this point in the history
This field is suppose to be used to track the number of primary names in
the symtab. It was not being updated or used.

Increment the nprim field when a new datum is added to the symtab and
decrement the field when a datum is removed.

Signed-off-by: James Carter <jwcart2@gmail.com>
  • Loading branch information
jwcart2 authored and fishilico committed Jan 20, 2021
1 parent 579d851 commit 7c65a5d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libsepol/cil/src/cil_symtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ int cil_symtab_insert(symtab_t *symtab, hashtab_key_t key, struct cil_symtab_dat
datum->name = key;
datum->fqn = key;
datum->symtab = symtab;
symtab->nprim++;
cil_list_append(datum->nodes, CIL_NODE, node);
} else if (rc == SEPOL_EEXIST) {
cil_list_append(datum->nodes, CIL_NODE, node);
Expand All @@ -111,6 +112,7 @@ void cil_symtab_remove_datum(struct cil_symtab_datum *datum)
}

hashtab_remove(symtab->table, datum->name, NULL, NULL);
symtab->nprim--;
datum->symtab = NULL;
}

Expand Down

0 comments on commit 7c65a5d

Please sign in to comment.