[liberty] Fix use-before-free bug

Before this change, findTableTemplate captured `name` always. This caused a segfault
when LibertyReader::beginTable calls it with `template_name`:

  const char *template_name = group->firstName();
  if (library_ && template_name) {
    tbl_template_ = library_->findTableTemplate(template_name, type);

This pointer is owned by the group and is freed when we hit sta::libertyGroupEnd.

Ensure that findTableTemplate does not capture `name` by using findKey.
This commit is contained in:
jmolloy 2025-01-10 16:42:57 +00:00
parent dfbce665ae
commit 57f6eb6cc3
1 changed files with 1 additions and 1 deletions

View File

@ -219,7 +219,7 @@ TableTemplate *
LibertyLibrary::findTableTemplate(const char *name,
TableTemplateType type)
{
return template_maps_[int(type)][name];
return template_maps_[int(type)].findKey(name);
}
TableTemplateSeq