diff --git a/parser/parser_yacc.y b/parser/parser_yacc.y index 0b5d4111f..0e4e4a643 100644 --- a/parser/parser_yacc.y +++ b/parser/parser_yacc.y @@ -577,6 +577,7 @@ flags: opt_flags TOK_OPENPAREN flagvals TOK_CLOSEPAREN flagvals: flagvals flagval { $1.merge($2); + $2.clear(); $$ = $1; }; diff --git a/parser/profile.cc b/parser/profile.cc index 52a195b9d..2e46ddf22 100644 --- a/parser/profile.cc +++ b/parser/profile.cc @@ -78,6 +78,7 @@ void ProfileList::dump_profile_names(bool children) Profile::~Profile() { hat_table.clear(); + flags.clear(); free_cod_entries(entries); free_cond_entry_list(xattrs); @@ -97,10 +98,6 @@ Profile::~Profile() free(name); if (attachment) free(attachment); - if (flags.disconnected_path) - free(flags.disconnected_path); - if (flags.disconnected_ipc) - free(flags.disconnected_ipc); if (ns) free(ns); for (int i = (AA_EXEC_LOCAL >> 10) + 1; i < AA_EXEC_COUNT; i++) diff --git a/parser/profile.h b/parser/profile.h index e7df0f90e..313940167 100644 --- a/parser/profile.h +++ b/parser/profile.h @@ -175,6 +175,12 @@ public: signal = 0; error = 0; } + + void clear(void) { + free(disconnected_path); + free(disconnected_ipc); + } + void init(const char *str) { init(); @@ -301,7 +307,7 @@ public: } // same ignore rhs.disconnect_path } else { - disconnected_path = rhs.disconnected_path; + disconnected_path = strdup(rhs.disconnected_path); } } if (rhs.disconnected_ipc) { @@ -311,7 +317,7 @@ public: } // same so do nothing } else { - disconnected_ipc = rhs.disconnected_ipc; + disconnected_ipc = strdup(rhs.disconnected_ipc); } } if (rhs.signal) {