File: | xattr.c |
Function: | get_all |
Error: | ob_refcnt of '*mylist' is 1 too high |
371 static PyObject *
372 get_all(PyObject *self, PyObject *args, PyObject *keywds)
373 {
374 PyObject *myarg, *res;
375 int dolink=0;
376 char *ns = NULL;
377 char *buf_list, *buf_val;
378 char *s;
379 ssize_t nalloc, nlist, nval;
380 PyObject *mylist;
381 target_t tgt;
382 static char *kwlist[] = {"item", "nofollow", "namespace", NULL};
383
384 /* Parse the arguments */
385 if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|iz", kwlist,
when _PyArg_ParseTupleAndKeywords_SizeT() succeeds
taking False path
386 &myarg, &dolink, &ns))
387 return NULL;
388 if(!convertObj(myarg, &tgt, dolink))
when considering range: -0x80000000 <= value <= -1
taking False path
389 return NULL;
390
391 /* Compute first the list of attributes */
392
393 /* Find out the needed size of the buffer for the attribute list */
394 nalloc = _list_obj(&tgt, NULL, 0);
395
396 if(nalloc == -1) {
when considering range: -0x8000000000000000 <= value <= -2
taking False path
397 res = PyErr_SetFromErrno(PyExc_IOError);
398 goto freetgt;
399 }
400
401 /* Try to allocate the memory, using Python's allocator */
402 if((buf_list = PyMem_Malloc(nalloc)) == NULL) {
when PyMem_Malloc() succeeds
taking False path
403 res = PyErr_NoMemory();
404 goto freetgt;
405 }
406
407 /* Now retrieve the list of attributes */
408 nlist = _list_obj(&tgt, buf_list, nalloc);
409
410 if(nlist == -1) {
when considering range: -0x8000000000000000 <= value <= -2
taking False path
411 res = PyErr_SetFromErrno(PyExc_IOError);
412 goto free_buf_list;
413 }
414
415 /* Create the list which will hold the result */
416 mylist = PyList_New(0);
when PyList_New() succeeds
PyListObject allocated at: mylist = PyList_New(0);
ob_refcnt is now refs: 1 + N where N >= 0
417 nalloc = ESTIMATE_ATTR_SIZE;
418 if((buf_val = PyMem_Malloc(nalloc)) == NULL) {
when PyMem_Malloc() succeeds
taking False path
419 Py_DECREF(mylist);
420 res = PyErr_NoMemory();
421 goto free_buf_list;
422 }
423
424 /* Create and insert the attributes as strings in the list */
425 for(s = buf_list; s - buf_list < nlist; s += strlen(s) + 1) {
when taking True path
426 PyObject *my_tuple;
427 int missing;
428 const char *name;
429
430 if((name=matches_ns(ns, s))==NULL)
when treating unknown const char * from xattr.c:430 as non-NULL
taking False path
431 continue;
432 /* Now retrieve the attribute value */
433 missing = 0;
434 while(1) {
435 nval = _get_obj(&tgt, s, buf_val, nalloc);
436
437 if(nval == -1) {
when considering value == (ssize_t)-1 from xattr.c:435
taking True path
438 if(errno == ERANGE) {
when treating unknown int * from xattr.c:438 as non-NULL
when considering range: -0x80000000 <= value <= 33
taking False path
439 nval = _get_obj(&tgt, s, NULL, 0);
440 if((buf_val = PyMem_Realloc(buf_val, nval)) == NULL) {
441 res = NULL;
442 Py_DECREF(mylist);
443 goto free_buf_list;
444 }
445 nalloc = nval;
446 continue;
447 } else if(errno == ENODATA || errno == ENOATTR) {
when treating unknown int * from xattr.c:447 as non-NULL
when considering range: -0x80000000 <= value <= 60
taking False path
448 /* this attribute has gone away since we queried
449 the attribute list */
450 missing = 1;
451 break;
452 }
453 res = PyErr_SetFromErrno(PyExc_IOError);
PyErr_SetFromErrno()
454 goto freebufval;
455 }
456 break;
457 }
458 if(missing)
459 continue;
460 #ifdef IS_PY3K
461 my_tuple = Py_BuildValue("yy#", name, buf_val, nval);
462 #else
463 my_tuple = Py_BuildValue("ss#", name, buf_val, nval);
464 #endif
465
466 PyList_Append(mylist, my_tuple);
467 Py_DECREF(my_tuple);
468 }
469
470 /* Successfull exit */
471 res = mylist;
472
473 freebufval:
474 PyMem_Free(buf_val);
calling PyMem_Free on PyMem_Malloc allocated at xattr.c:418
475
476 free_buf_list:
477 PyMem_Free(buf_list);
calling PyMem_Free on PyMem_Malloc allocated at xattr.c:402
478
479 freetgt:
480 free_tgt(&tgt);
481
482 /* Return the result */
483 return res;
484 }
ob_refcnt of '*mylist' is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1
found 1 similar trace(s) to this
File: | xattr.c |
Function: | get_all |
Error: | dereferencing NULL (my_tuple->ob_refcnt) at xattr.c:467 |
371 static PyObject *
372 get_all(PyObject *self, PyObject *args, PyObject *keywds)
373 {
374 PyObject *myarg, *res;
375 int dolink=0;
376 char *ns = NULL;
377 char *buf_list, *buf_val;
378 char *s;
379 ssize_t nalloc, nlist, nval;
380 PyObject *mylist;
381 target_t tgt;
382 static char *kwlist[] = {"item", "nofollow", "namespace", NULL};
383
384 /* Parse the arguments */
385 if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|iz", kwlist,
when _PyArg_ParseTupleAndKeywords_SizeT() succeeds
taking False path
386 &myarg, &dolink, &ns))
387 return NULL;
388 if(!convertObj(myarg, &tgt, dolink))
when considering range: -0x80000000 <= value <= -1
taking False path
389 return NULL;
390
391 /* Compute first the list of attributes */
392
393 /* Find out the needed size of the buffer for the attribute list */
394 nalloc = _list_obj(&tgt, NULL, 0);
395
396 if(nalloc == -1) {
when considering range: -0x8000000000000000 <= value <= -2
taking False path
397 res = PyErr_SetFromErrno(PyExc_IOError);
398 goto freetgt;
399 }
400
401 /* Try to allocate the memory, using Python's allocator */
402 if((buf_list = PyMem_Malloc(nalloc)) == NULL) {
when PyMem_Malloc() succeeds
taking False path
403 res = PyErr_NoMemory();
404 goto freetgt;
405 }
406
407 /* Now retrieve the list of attributes */
408 nlist = _list_obj(&tgt, buf_list, nalloc);
409
410 if(nlist == -1) {
when considering range: -0x8000000000000000 <= value <= -2
taking False path
411 res = PyErr_SetFromErrno(PyExc_IOError);
412 goto free_buf_list;
413 }
414
415 /* Create the list which will hold the result */
416 mylist = PyList_New(0);
when PyList_New() succeeds
417 nalloc = ESTIMATE_ATTR_SIZE;
418 if((buf_val = PyMem_Malloc(nalloc)) == NULL) {
when PyMem_Malloc() succeeds
taking False path
419 Py_DECREF(mylist);
420 res = PyErr_NoMemory();
421 goto free_buf_list;
422 }
423
424 /* Create and insert the attributes as strings in the list */
425 for(s = buf_list; s - buf_list < nlist; s += strlen(s) + 1) {
when taking True path
426 PyObject *my_tuple;
427 int missing;
428 const char *name;
429
430 if((name=matches_ns(ns, s))==NULL)
when treating unknown const char * from xattr.c:430 as non-NULL
taking False path
431 continue;
432 /* Now retrieve the attribute value */
433 missing = 0;
434 while(1) {
435 nval = _get_obj(&tgt, s, buf_val, nalloc);
436
437 if(nval == -1) {
when considering range: -0x8000000000000000 <= value <= -2
taking False path
438 if(errno == ERANGE) {
439 nval = _get_obj(&tgt, s, NULL, 0);
440 if((buf_val = PyMem_Realloc(buf_val, nval)) == NULL) {
441 res = NULL;
442 Py_DECREF(mylist);
443 goto free_buf_list;
444 }
445 nalloc = nval;
446 continue;
447 } else if(errno == ENODATA || errno == ENOATTR) {
448 /* this attribute has gone away since we queried
449 the attribute list */
450 missing = 1;
451 break;
452 }
453 res = PyErr_SetFromErrno(PyExc_IOError);
454 goto freebufval;
455 }
456 break;
457 }
458 if(missing)
taking False path
459 continue;
460 #ifdef IS_PY3K
461 my_tuple = Py_BuildValue("yy#", name, buf_val, nval);
462 #else
463 my_tuple = Py_BuildValue("ss#", name, buf_val, nval);
when _Py_BuildValue_SizeT() fails
464 #endif
465
466 PyList_Append(mylist, my_tuple);
returning -1 from PyList_Append() due to NULL item
467 Py_DECREF(my_tuple);
dereferencing NULL (my_tuple->ob_refcnt) at xattr.c:467
468 }
469
470 /* Successfull exit */
471 res = mylist;
472
473 freebufval:
474 PyMem_Free(buf_val);
475
476 free_buf_list:
477 PyMem_Free(buf_list);
478
479 freetgt:
480 free_tgt(&tgt);
481
482 /* Return the result */
483 return res;
484 }