Fix memory leak when resolving named instances in fonts

We need to free the memory allocated when getting the
info about the variable font.

Change-Id: I25c5f070a6d02468c904428ea2ae71efce1e847c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2023-11-02 10:16:34 +01:00
parent 3bae65e7d6
commit c22ff83b2a

View File

@ -107,6 +107,10 @@ void QFreeTypeFontDatabase::addNamedInstancesForFace(void *face_,
FT_MM_Var *var = nullptr;
FT_Get_MM_Var(face, &var);
if (var != nullptr) {
std::unique_ptr<FT_MM_Var, void(*)(FT_MM_Var*)> varGuard(var, [](FT_MM_Var *res) {
FT_Done_MM_Var(qt_getFreetype(), res);
});
for (FT_UInt i = 0; i < var->num_namedstyles; ++i) {
FT_UInt id = var->namedstyle[i].strid;