Move creation of dictionary to a point after error handling, when it is relatively certain that the function will succeed.

(cherry picked from commit 1820716a4bc018bb903b95bcf5d7cf83a5ebda9c)
This commit is contained in:
Ronald van Elburg
2021-04-02 13:15:56 +02:00
parent 97f2abcb30
commit e6a6445375

View File

@@ -640,7 +640,7 @@ alsapcm_dumpinfo(alsapcm_t *self, PyObject *args)
static PyObject *
alsapcm_info(alsapcm_t *self, PyObject *args)
{
PyObject *info = PyDict_New();
PyObject *info;
PyObject *value;
unsigned int val,val2;
@@ -659,6 +659,8 @@ alsapcm_info(alsapcm_t *self, PyObject *args)
return NULL;
}
info = PyDict_New();
value=PyUnicode_FromString(snd_pcm_name(self->handle));
PyDict_SetItemString(info,"name",value);
Py_DECREF(value);