libdrgn: fix memory leak of type template parameters

We never free drgn_type::template_parameters.

Fixes: 352c31e1ac ("Add support for C++ template parameters")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
Omar Sandoval 2024-01-16 01:17:07 -08:00
parent d22f434600
commit 71a65dbfb1

View File

@ -1291,6 +1291,15 @@ void drgn_program_deinit_types(struct drgn_program *prog)
drgn_lazy_object_deinit(&parameters[j].default_argument);
free(parameters);
}
if (drgn_type_has_template_parameters(type)) {
struct drgn_type_template_parameter *template_parameters =
drgn_type_template_parameters(type);
size_t num_template_parameters =
drgn_type_num_template_parameters(type);
for (size_t j = 0; j < num_template_parameters; j++)
drgn_lazy_object_deinit(&template_parameters[j].argument);
free(template_parameters);
}
free(type);
}
drgn_typep_vector_deinit(&prog->created_types);