From 05b265bd0b904abe07d98f4e8c5b675a2fbbd1b8 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 5 Jan 2025 14:44:02 +1100 Subject: [PATCH] Simplified code --- src/_imagingft.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/_imagingft.c b/src/_imagingft.c index d38279f3e4b..6cdbd6d8494 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -339,22 +339,19 @@ text_layout_raqm( len = PySequence_Fast_GET_SIZE(seq); for (j = 0; j < len; j++) { PyObject *item = PySequence_Fast_GET_ITEM(seq, j); - char *feature = NULL; - Py_ssize_t size = 0; - PyObject *bytes; + char *feature; + Py_ssize_t size; if (!PyUnicode_Check(item)) { Py_DECREF(seq); PyErr_SetString(PyExc_TypeError, "expected a string"); goto failed; } - bytes = PyUnicode_AsUTF8String(item); - if (bytes == NULL) { + feature = PyUnicode_AsUTF8AndSize(item, size); + if (feature == NULL) { Py_DECREF(seq); goto failed; } - feature = PyBytes_AS_STRING(bytes); - size = PyBytes_GET_SIZE(bytes); if (!raqm_add_font_feature(rq, feature, size)) { Py_DECREF(seq); Py_DECREF(bytes);