Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support patternized module name for dynamic patch #1211

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions libmcount/dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,22 @@ static int do_dynamic_update(struct symtabs *symtabs, char *patch_funcs,
}

while (!list_empty(&patterns)) {
struct func_patt_list *pl;
struct module_patt_list *ml;

ml = list_first_entry(&patterns, struct module_patt_list, list);
while (!list_empty(&ml->func_patt)) {
struct func_patt_list *pl;

pl = list_first_entry(&patterns, struct func_patt_list, list);
pl = list_first_entry(&ml->func_patt, struct func_patt_list, list);

list_del(&pl->list);
free(pl->module);
free(pl);
}

list_del(&pl->list);
free(pl->module);
free(pl);
list_del(&ml->list);
free(ml->module);
free(ml);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I think it's better to put the release code along with the allocation code. So we can easily find where they are and make sure not to create any leaks.

Also please consider adding an unit test for new functionalities. It's also good to check memory errors with ASAN.

}

strv_free(&funcs);
Expand Down