File: | alsaaudio.c |
Function: | alsamixer_getvolume |
Error: | calling PyList_Append with NULL as argument 1 (result) at alsaaudio.c:1437 |
1378 static PyObject *
1379 alsamixer_getvolume(alsamixer_t *self, PyObject *args)
1380 {
1381 snd_mixer_elem_t *elem;
1382 int direction;
1383 int channel;
1384 long ival;
1385 char *dirstr = 0;
1386 PyObject *result;
1387 PyObject *item;
1388
1389 if (!PyArg_ParseTuple(args,"|s:getvolume",&dirstr))
when PyArg_ParseTuple() succeeds
taking False path
1390 return NULL;
1391
1392 if (!self->handle)
when treating unknown struct snd_mixer_t * from alsaaudio.c:1392 as non-NULL
taking False path
1393 {
1394 PyErr_SetString(ALSAAudioError, "Mixer is closed");
1395 return NULL;
1396 }
1397
1398 elem = alsamixer_find_elem(self->handle,self->controlname,self->controlid);
1399
1400 if (!dirstr)
when treating unknown const char * from alsaaudio.c:1389 as non-NULL
taking False path
1401 {
1402 if (self->pchannels)
1403 direction = 0;
1404 else
1405 direction = 1;
1406 }
1407 else if (strcasecmp(dirstr,"playback")==0)
when considering range: -0x80000000 <= value <= -1
taking False path
1408 direction = 0;
1409 else if (strcasecmp(dirstr,"capture")==0)
when considering value == (int)0 from alsaaudio.c:1409
taking True path
1410 direction = 1;
1411 else
1412 {
1413 PyErr_SetString(ALSAAudioError,"Invalid direction argument for mixer");
1414 return NULL;
1415 }
1416
1417 result = PyList_New(0);
when PyList_New() fails
1418
1419 for (channel = 0; channel <= SND_MIXER_SCHN_LAST; channel++) {
taking True path
1420 if (direction == 0 &&
taking False path
1421 snd_mixer_selem_has_playback_channel(elem, channel))
1422 {
1423 snd_mixer_selem_get_playback_volume(elem, channel, &ival);
1424 item = PyLong_FromLong(alsamixer_getpercentage(self->pmin,
1425 self->pmax,
1426 ival));
1427 PyList_Append(result, item);
1428 Py_DECREF(item);
1429 }
1430 else if (direction == 1
taking True path
1431 && snd_mixer_selem_has_capture_channel(elem, channel)
when considering range: -0x80000000 <= value <= -1
taking True path
1432 && snd_mixer_selem_has_capture_volume(elem)) {
when considering range: -0x80000000 <= value <= -1
taking True path
1433 snd_mixer_selem_get_capture_volume(elem, channel, &ival);
1434 item = PyLong_FromLong(alsamixer_getpercentage(self->cmin,
when PyLong_FromLong() succeeds
1435 self->cmax,
1436 ival));
1437 PyList_Append(result, item);
calling PyList_Append with NULL as argument 1 (result) at alsaaudio.c:1437
PyList_Append() invokes Py_TYPE() on the pointer via the PyList_Check() macro, thus accessing (NULL)->ob_type
found 3 similar trace(s) to this
1438 Py_DECREF(item);
1439 }
1440 }
1441
1442 return result;
1443 }
File: | alsaaudio.c |
Function: | alsamixer_getvolume |
Error: | dereferencing NULL (item->ob_refcnt) at alsaaudio.c:1438 |
1378 static PyObject *
1379 alsamixer_getvolume(alsamixer_t *self, PyObject *args)
1380 {
1381 snd_mixer_elem_t *elem;
1382 int direction;
1383 int channel;
1384 long ival;
1385 char *dirstr = 0;
1386 PyObject *result;
1387 PyObject *item;
1388
1389 if (!PyArg_ParseTuple(args,"|s:getvolume",&dirstr))
when PyArg_ParseTuple() succeeds
taking False path
1390 return NULL;
1391
1392 if (!self->handle)
when treating unknown struct snd_mixer_t * from alsaaudio.c:1392 as non-NULL
taking False path
1393 {
1394 PyErr_SetString(ALSAAudioError, "Mixer is closed");
1395 return NULL;
1396 }
1397
1398 elem = alsamixer_find_elem(self->handle,self->controlname,self->controlid);
1399
1400 if (!dirstr)
when treating unknown const char * from alsaaudio.c:1389 as non-NULL
taking False path
1401 {
1402 if (self->pchannels)
1403 direction = 0;
1404 else
1405 direction = 1;
1406 }
1407 else if (strcasecmp(dirstr,"playback")==0)
when considering range: -0x80000000 <= value <= -1
taking False path
1408 direction = 0;
1409 else if (strcasecmp(dirstr,"capture")==0)
when considering value == (int)0 from alsaaudio.c:1409
taking True path
1410 direction = 1;
1411 else
1412 {
1413 PyErr_SetString(ALSAAudioError,"Invalid direction argument for mixer");
1414 return NULL;
1415 }
1416
1417 result = PyList_New(0);
when PyList_New() succeeds
1418
1419 for (channel = 0; channel <= SND_MIXER_SCHN_LAST; channel++) {
taking True path
1420 if (direction == 0 &&
taking False path
1421 snd_mixer_selem_has_playback_channel(elem, channel))
1422 {
1423 snd_mixer_selem_get_playback_volume(elem, channel, &ival);
1424 item = PyLong_FromLong(alsamixer_getpercentage(self->pmin,
1425 self->pmax,
1426 ival));
1427 PyList_Append(result, item);
1428 Py_DECREF(item);
1429 }
1430 else if (direction == 1
taking True path
1431 && snd_mixer_selem_has_capture_channel(elem, channel)
when considering range: -0x80000000 <= value <= -1
taking True path
1432 && snd_mixer_selem_has_capture_volume(elem)) {
when considering range: -0x80000000 <= value <= -1
taking True path
1433 snd_mixer_selem_get_capture_volume(elem, channel, &ival);
1434 item = PyLong_FromLong(alsamixer_getpercentage(self->cmin,
when PyLong_FromLong() fails
1435 self->cmax,
1436 ival));
1437 PyList_Append(result, item);
returning -1 from PyList_Append() due to NULL item
1438 Py_DECREF(item);
dereferencing NULL (item->ob_refcnt) at alsaaudio.c:1438
found 3 similar trace(s) to this
1439 }
1440 }
1441
1442 return result;
1443 }