Skip to content

Commit 1c61629

Browse files
committed
Decrement reference count
1 parent 946a4de commit 1c61629

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/_avif.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,18 +1006,15 @@ static PyMethodDef avifMethods[] = {
10061006

10071007
static int
10081008
setup_module(PyObject *m) {
1009-
PyObject *d = PyModule_GetDict(m);
1010-
1011-
PyObject *v = PyUnicode_FromString(avifVersion());
1012-
if (PyDict_SetItemString(d, "libavif_version", v) < 0) {
1013-
Py_DECREF(v);
1014-
return -1;
1015-
}
1016-
Py_DECREF(v);
1017-
10181009
if (PyType_Ready(&AvifDecoder_Type) < 0 || PyType_Ready(&AvifEncoder_Type) < 0) {
10191010
return -1;
10201011
}
1012+
1013+
PyObject *d = PyModule_GetDict(m);
1014+
PyObject *v = PyUnicode_FromString(avifVersion());
1015+
PyDict_SetItemString(d, "libavif_version", v ? v : Py_None);
1016+
Py_XDECREF(v);
1017+
10211018
return 0;
10221019
}
10231020

@@ -1034,6 +1031,7 @@ PyInit__avif(void) {
10341031

10351032
m = PyModule_Create(&module_def);
10361033
if (setup_module(m) < 0) {
1034+
Py_DECREF(m);
10371035
return NULL;
10381036
}
10391037

0 commit comments

Comments
 (0)