File: xattr.c
Function: xattr_list
Error: dereferencing NULL (MEM[(struct PyListObject *)res].ob_item) at xattr.c:942
889 static PyObject *
890 xattr_list(PyObject *self, PyObject *args, PyObject *keywds)
891 {
892     char *buf;
893     int nofollow = 0;
894     ssize_t nalloc, nret;
895     PyObject *myarg;
896     PyObject *res;
897     char *ns = NULL;
898     Py_ssize_t nattrs;
899     char *s;
900     target_t tgt;
901     static char *kwlist[] = {"item", "nofollow", "namespace", NULL};
902 
903     /* Parse the arguments */
904     if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|iet", kwlist,
when _PyArg_ParseTupleAndKeywords_SizeT() succeeds
taking False path
905                                      &myarg, &nofollow, NULL, &ns))
906         return NULL;
907     if(!convertObj(myarg, &tgt, nofollow)) {
when considering range: -0x80000000 <= value <= -1
taking False path
908         res = NULL;
909         goto freearg;
910     }
911 
912     /* Find out the needed size of the buffer */
913     if((nalloc = _list_obj(&tgt, NULL, 0)) == -1) {
when considering range: -0x8000000000000000 <= value <= -2
taking False path
914         res = PyErr_SetFromErrno(PyExc_IOError);
915         goto freetgt;
916     }
917 
918     /* Try to allocate the memory, using Python's allocator */
919     if((buf = PyMem_Malloc(nalloc)) == NULL) {
when PyMem_Malloc() succeeds
taking False path
920         res = PyErr_NoMemory();
921         goto freetgt;
922     }
923 
924     /* Now retrieve the list of attributes */
925     if((nret = _list_obj(&tgt, buf, nalloc)) == -1) {
when considering range: -0x8000000000000000 <= value <= -2
taking False path
926         res = PyErr_SetFromErrno(PyExc_IOError);
927         goto freebuf;
928     }
929 
930     /* Compute the number of attributes in the list */
931     for(s = buf, nattrs = 0; (s - buf) < nret; s += strlen(s) + 1) {
when taking True path
when taking False path
932         if(matches_ns(ns, s) != NULL)
when treating unknown const char * from xattr.c:932 as non-NULL
taking True path
933             nattrs++;
934     }
935     /* Create the list which will hold the result */
936     res = PyList_New(nattrs);
when PyList_New() fails
937 
938     /* Create and insert the attributes as strings in the list */
939     for(s = buf, nattrs = 0; s - buf < nret; s += strlen(s) + 1) {
when taking True path
940         const char *name = matches_ns(ns, s);
941         if(name!=NULL) {
when treating unknown const char * from xattr.c:940 as non-NULL
taking True path
942             PyList_SET_ITEM(res, nattrs, PyBytes_FromString(name));
dereferencing NULL (MEM[(struct PyListObject *)res].ob_item) at xattr.c:942
943             nattrs++;
944         }
945     }
946 
947  freebuf:
948     /* Free the buffer, now it is no longer needed */
949     PyMem_Free(buf);
950 
951  freetgt:
952     free_tgt(&tgt);
953  freearg:
954     PyMem_Free(ns);
955 
956     /* Return the result */
957     return res;
958 }