Skip to content

Commit

Permalink
Decrement reference count
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Mar 11, 2023
1 parent 929dbba commit b3d7823
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,7 @@ PyInit__imaging(void) {
m = PyModule_Create(&module_def);

if (setup_module(m) < 0) {
Py_DECREF(m);
return NULL;
}

Expand Down
12 changes: 12 additions & 0 deletions src/_imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,7 @@ font_getvarnames(FontObject *self) {
for (i = 0; i < name_count; i++) {
error = FT_Get_Sfnt_Name(self->face, i, &name);
if (error) {
Py_DECREF(list_names);
return geterror(error);
}

Expand Down Expand Up @@ -1136,6 +1137,11 @@ font_getvaraxes(FontObject *self) {

list_axis = PyDict_New();
if (list_axis == NULL) {
for (j = 0; j < i; j++) {
list_axis = PyList_GetItem(list_axes, j);
Py_DECREF(list_axis);
}
Py_DECREF(list_axes);
return NULL;
}
PyDict_SetItemString(
Expand All @@ -1147,6 +1153,12 @@ font_getvaraxes(FontObject *self) {
for (j = 0; j < name_count; j++) {
error = FT_Get_Sfnt_Name(self->face, j, &name);
if (error) {
Py_DECREF(list_axis);
for (j = 0; j < i; j++) {
list_axis = PyList_GetItem(list_axes, j);
Py_DECREF(list_axis);
}
Py_DECREF(list_axes);
return geterror(error);
}

Expand Down
5 changes: 5 additions & 0 deletions src/_imagingmorph.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,21 @@ match(PyObject *self, PyObject *args) {
}

if (!PyArg_ParseTuple(args, "On", &py_lut, &i0)) {
Py_DECREF(ret);
PyErr_SetString(PyExc_RuntimeError, "Argument parsing problem");
return NULL;
}

if (!PyBytes_Check(py_lut)) {
Py_DECREF(ret);
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a bytes object");
return NULL;
}

lut_len = PyBytes_Size(py_lut);

if (lut_len < LUT_SIZE) {
Py_DECREF(ret);
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size");
return NULL;
}
Expand All @@ -161,6 +164,7 @@ match(PyObject *self, PyObject *args) {
imgin = (Imaging)i0;

if (imgin->type != IMAGING_TYPE_UINT8 || imgin->bands != 1) {
Py_DECREF(ret);
PyErr_SetString(PyExc_RuntimeError, "Unsupported image type");
return NULL;
}
Expand Down Expand Up @@ -221,6 +225,7 @@ get_on_pixels(PyObject *self, PyObject *args) {
}

if (!PyArg_ParseTuple(args, "n", &i0)) {
Py_DECREF(ret);
PyErr_SetString(PyExc_RuntimeError, "Argument parsing problem");
return NULL;
}
Expand Down
6 changes: 5 additions & 1 deletion src/_imagingtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ PyInit__imagingtk(void) {
};
PyObject *m;
m = PyModule_Create(&module_def);
return (load_tkinter_funcs() == 0) ? m : NULL;
if (load_tkinter_funcs() != 0) {
Py_DECREF(m);
return NULL;;
}
return m;
}
1 change: 1 addition & 0 deletions src/_webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ PyInit__webp(void) {

m = PyModule_Create(&module_def);
if (setup_module(m) < 0) {
Py_DECREF(m);
return NULL;
}

Expand Down

0 comments on commit b3d7823

Please sign in to comment.