[PATCH]fix maat_state_free_bytes statistics error

This commit is contained in:
liuwentan
2023-09-21 09:30:07 +08:00
parent 4f5f5a1c84
commit 2a9ba6c08f
2 changed files with 6 additions and 5 deletions

View File

@@ -125,6 +125,7 @@ typedef struct {
} while(0) } while(0)
#define utarray_len(a) ((a)->i) #define utarray_len(a) ((a)->i)
#define utarray_size(a) ((a)->n)
#define utarray_eltptr(a,j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL) #define utarray_eltptr(a,j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL)
#define _utarray_eltptr(a,j) ((void*)((a)->d + ((a)->icd.sz * (j)))) #define _utarray_eltptr(a,j) ((void*)((a)->d + ((a)->icd.sz * (j))))

View File

@@ -1381,33 +1381,33 @@ void maat_compile_state_free(struct maat_compile_state *compile_state,
long long free_bytes = 0; long long free_bytes = 0;
if (compile_state->internal_hit_paths != NULL) { if (compile_state->internal_hit_paths != NULL) {
free_bytes += utarray_len(compile_state->internal_hit_paths) * free_bytes += utarray_size(compile_state->internal_hit_paths) *
sizeof(struct maat_internal_hit_path); sizeof(struct maat_internal_hit_path);
utarray_free(compile_state->internal_hit_paths); utarray_free(compile_state->internal_hit_paths);
compile_state->internal_hit_paths = NULL; compile_state->internal_hit_paths = NULL;
} }
if (compile_state->internal_inc_hit_paths != NULL) { if (compile_state->internal_inc_hit_paths != NULL) {
free_bytes += utarray_len(compile_state->internal_inc_hit_paths) * free_bytes += utarray_size(compile_state->internal_inc_hit_paths) *
sizeof(struct maat_internal_hit_path); sizeof(struct maat_internal_hit_path);
utarray_free(compile_state->internal_inc_hit_paths); utarray_free(compile_state->internal_inc_hit_paths);
compile_state->internal_inc_hit_paths = NULL; compile_state->internal_inc_hit_paths = NULL;
} }
if (compile_state->all_hit_clauses != NULL) { if (compile_state->all_hit_clauses != NULL) {
free_bytes += utarray_len(compile_state->all_hit_clauses) * sizeof(long long); free_bytes += utarray_size(compile_state->all_hit_clauses) * sizeof(long long);
utarray_free(compile_state->all_hit_clauses); utarray_free(compile_state->all_hit_clauses);
compile_state->all_hit_clauses = NULL; compile_state->all_hit_clauses = NULL;
} }
if (compile_state->this_scan_hit_clauses != NULL) { if (compile_state->this_scan_hit_clauses != NULL) {
free_bytes += utarray_len(compile_state->this_scan_hit_clauses) * sizeof(long long); free_bytes += utarray_size(compile_state->this_scan_hit_clauses) * sizeof(long long);
utarray_free(compile_state->this_scan_hit_clauses); utarray_free(compile_state->this_scan_hit_clauses);
compile_state->this_scan_hit_clauses = NULL; compile_state->this_scan_hit_clauses = NULL;
} }
if (compile_state->indirect_hit_groups != NULL) { if (compile_state->indirect_hit_groups != NULL) {
free_bytes += utarray_len(compile_state->indirect_hit_groups) * sizeof(struct maat_hit_group); free_bytes += utarray_size(compile_state->indirect_hit_groups) * sizeof(struct maat_hit_group);
utarray_free(compile_state->indirect_hit_groups); utarray_free(compile_state->indirect_hit_groups);
compile_state->indirect_hit_groups = NULL; compile_state->indirect_hit_groups = NULL;
} }