From f5313db9ce5f800de29cb40af12c0722ecbe7173 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Sat, 13 Jul 2024 11:00:57 +0200 Subject: [PATCH] Add necessary PyMem_Free and fix PyDict_GetItemRef call --- src/_imagingft.c | 2 +- src/encode.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/_imagingft.c b/src/_imagingft.c index ddcf28f97eb..eb04945f032 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -1243,8 +1243,8 @@ font_getvarnames(FontObject *self) { } } + PyMem_Free(list_names_filled); FT_Done_MM_Var(library, master); - return list_names; } diff --git a/src/encode.c b/src/encode.c index 620774f67af..82aed77837c 100644 --- a/src/encode.c +++ b/src/encode.c @@ -723,8 +723,8 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) { if (!is_core_tag) { PyObject *tag_type; - if (PyDict_GetItemRef(types, key, &tag_type) == 0) { - PyErr_SetString(PyExc_KeyError, "unknown tag type"); + if (PyDict_GetItemRef(types, key, &tag_type) < 0) { + return NULL; // Exception has been already set } if (tag_type) { int type_int = PyLong_AsLong(tag_type);