[liberty] Fix use-before-free bug (#170)
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.
Co-authored-by: jmolloy <jmolloy@google.com>
This commit is contained in:
parent
c8e8661050
commit
7fbe386d35
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue