Fix crash on macOS when failing to get font_descriptor

This commit is contained in:
Kovid Goyal 2017-11-05 17:10:36 +05:30
parent e72f153a66
commit d05ea312ef
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -174,7 +174,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
Face *self;
PyObject *descriptor;
float point_sz, dpi;
if(!PyArg_ParseTuple(args, "Off", &descriptor, &point_sz, &dpi)) return NULL;
if (!PyArg_ParseTuple(args, "Off", &descriptor, &point_sz, &dpi)) return NULL;
self = (Face *)type->tp_alloc(type, 0);
if (self) {
CTFontDescriptorRef desc = font_descriptor_from_python(descriptor);
@ -194,7 +194,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
static void
dealloc(Face* self) {
CFRelease(self->descriptor);
if (self->descriptor) CFRelease(self->descriptor);
if (self->harfbuzz_font) hb_font_destroy(self->harfbuzz_font);
if (self->font) CFRelease(self->font);
Py_CLEAR(self->family_name); Py_CLEAR(self->full_name); Py_CLEAR(self->postscript_name); Py_CLEAR(self->path);