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

Fix ASAN issue in h5dump error path #1051

Merged
merged 2 commits into from
Oct 3, 2021
Merged
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
4 changes: 4 additions & 0 deletions tools/src/h5dump/h5dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,10 @@ main(int argc, const char *argv[])
if (table_list_add(fid, oi.fileno) < 0) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
/* table_list.nused will be zero and the added containers needs to be cleaned up */
HDfree(table_list.tables[0].group_table);
HDfree(table_list.tables[0].dset_table);
HDfree(table_list.tables[0].type_table);
goto done;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not very familiar with the code, but, generally, I think freeing should be done in done:, also, should table_list_free() be used somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally, yes, but these are pointers not captured anywhere else until later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume that since the sanitizer reported an issue, table_list_free() in done wasn't freeing these group, dset, and type tables belonging to table_list.tables[0]? Should table_list_free() in done (line 1614) have freed them? Is there a need to check that they exist before freeing them here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. If these lines stay there, the pointers need to be checked before freeing.

}
group_table = table_list.tables[0].group_table;
Expand Down