Skip to content

Commit d6a1caa

Browse files
committed
TerminalFont: fix resource leaks on macOS
1 parent ed5d729 commit d6a1caa

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/detection/terminalfont/terminalfont_apple.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ static const char* iterm2ParsePList(const FFinstance* instance, const FFstrbuf*
3232
else
3333
ffplist_from_xml(content->chars, content->length, &root_node);
3434

35+
const char* error = NULL;
36+
3537
if(root_node == NULL)
36-
return "parsing iTerm preference file failed";
38+
{
39+
error = "parsing iTerm preference file failed";
40+
goto exit;
41+
}
3742

3843
plist_t bookmarks = ffplist_access_path(root_node, 1, "New Bookmarks");
3944

@@ -50,20 +55,22 @@ static const char* iterm2ParsePList(const FFinstance* instance, const FFstrbuf*
5055

5156
if(item == NULL)
5257
{
53-
ffplist_free(root_node);
54-
return "find profile bookmark failed";
58+
error = "find profile bookmark failed";
59+
goto exit;
5560
}
5661

5762
item = ffplist_dict_get_item(item, "Normal Font");
5863
if (item == NULL)
5964
{
60-
ffplist_free(root_node);
61-
return "find Normal Font key failed";
65+
error = "find Normal Font key failed";
66+
goto exit;
6267
}
6368

6469
ffFontInitWithSpace(&terminalFont->font, ffplist_get_string_ptr(item, NULL));
6570

71+
exit:
6672
ffplist_free(root_node);
73+
dlclose(libplist);
6774
return NULL;
6875
}
6976

0 commit comments

Comments
 (0)