mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Fix memory leaks in coretext_all_fonts()
Found with the Clang Static Analyzer.
This commit is contained in:
@@ -161,12 +161,13 @@ coretext_all_fonts(PyObject UNUSED *_self) {
|
||||
CFArrayRef matches = CTFontCollectionCreateMatchingFontDescriptors(all_fonts_collection());
|
||||
const CFIndex count = CFArrayGetCount(matches);
|
||||
PyObject *ans = PyTuple_New(count), *temp;
|
||||
if (ans == NULL) return PyErr_NoMemory();
|
||||
if (ans == NULL) { CFRelease(matches); return PyErr_NoMemory(); }
|
||||
for (CFIndex i = 0; i < count; i++) {
|
||||
temp = font_descriptor_to_python((CTFontDescriptorRef) CFArrayGetValueAtIndex(matches, i));
|
||||
if (temp == NULL) { Py_DECREF(ans); return NULL; }
|
||||
if (temp == NULL) { CFRelease(matches); Py_DECREF(ans); return NULL; }
|
||||
PyTuple_SET_ITEM(ans, i, temp); temp = NULL;
|
||||
}
|
||||
CFRelease(matches);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user