Skip to content

Commit 0b2726e

Browse files
committed
Cleanup fc_match_postscript_name
1 parent bc7f689 commit 0b2726e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kitty/fontconfig.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,15 @@ fc_match(PyObject UNUSED *self, PyObject *args) {
205205

206206
static PyObject*
207207
fc_match_postscript_name(PyObject UNUSED *self, PyObject *args) {
208-
char *postscript_name = NULL;
208+
const char *postscript_name = NULL;
209209
FcPattern *pat = NULL;
210210
PyObject *ans = NULL;
211211

212-
if (!PyArg_ParseTuple(args, "|z", &postscript_name)) return NULL;
212+
if (!PyArg_ParseTuple(args, "s", &postscript_name)) return NULL;
213+
if (!postscript_name || !postscript_name[0]) { PyErr_SetString(PyExc_KeyError, "postscript_name must not be empty"); return NULL; }
214+
213215
pat = FcPatternCreate();
214216
if (pat == NULL) return PyErr_NoMemory();
215-
if (!postscript_name || strlen(postscript_name) == 0) return NULL;
216217

217218
AP(FcPatternAddString, FC_POSTSCRIPT_NAME, (const FcChar8*)postscript_name, "postscript_name");
218219

0 commit comments

Comments
 (0)