From a97ba08cbb9d022bbb6ba088d9e6e922a81f5038 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 13 Nov 2017 09:31:48 +0530 Subject: [PATCH] Fix asan test failure --- kitty/fonts.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kitty/fonts.c b/kitty/fonts.c index 8e62f895c..b429d9065 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -614,11 +614,9 @@ test_shape(PyObject UNUSED *self, PyObject *args) { if (path) { face = face_from_path(path, index); if (face == NULL) return NULL; - Font f = {0}; - font = &f; + font = calloc(1, sizeof(Font)); font->hb_font = harfbuzz_font_for_face(face); font->face = face; - if (!font->hb_font) return NULL; } hb_shape(font->hb_font, harfbuzz_buffer, NULL, 0); hb_glyph_info_t *info; @@ -633,7 +631,7 @@ test_shape(PyObject UNUSED *self, PyObject *args) { PyList_Append(ans, Py_BuildValue("IIIK", num_group_cells, num_group_glyphs, first_glyph, extra_glyphs)); run_pos += num_group_glyphs; cell_pos += num_group_cells; } - Py_CLEAR(face); + if (face) { Py_CLEAR(face); free(font); } return ans; }