Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08673c5

Browse files
committed
fix refleak on error
1 parent 77b286b commit 08673c5

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Modules/audioop.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ audioop_lin2adpcm_impl(PyModuleDef *module, Py_buffer *fragment, int width, PyOb
16081608
Py_ssize_t i;
16091609
int step, valpred, delta,
16101610
index, sign, vpdiff, diff;
1611-
PyObject *rv, *str;
1611+
PyObject *rv = NULL, *str;
16121612
int outputbuffer = 0, bufferstep;
16131613

16141614
if (!audioop_check_parameters(fragment->len, width))
@@ -1626,9 +1626,10 @@ audioop_lin2adpcm_impl(PyModuleDef *module, Py_buffer *fragment, int width, PyOb
16261626
index = 0;
16271627
} else if (!PyTuple_Check(state)) {
16281628
PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
1629-
return NULL;
1630-
} else if (!PyArg_ParseTuple(state, "ii", &valpred, &index))
1631-
return NULL;
1629+
goto exit;
1630+
} else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) {
1631+
goto exit;
1632+
}
16321633

16331634
step = stepsizeTable[index];
16341635
bufferstep = 1;
@@ -1704,6 +1705,8 @@ audioop_lin2adpcm_impl(PyModuleDef *module, Py_buffer *fragment, int width, PyOb
17041705
bufferstep = !bufferstep;
17051706
}
17061707
rv = Py_BuildValue("(O(ii))", str, valpred, index);
1708+
1709+
exit:
17071710
Py_DECREF(str);
17081711
return rv;
17091712
}

0 commit comments

Comments
 (0)