diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-02 05:53:11 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-02 05:53:11 +0200 |
commit | 986fb8aeb82013bf9e18a0c006138f7d3032dfb7 (patch) | |
tree | 6372938314a056223bb4dc8404a3654f7352fb7f /psutil/_psutil_sunos.c | |
parent | b6cb551bb68d7985b8796370fd8ba856dbc2859e (diff) | |
download | psutil-986fb8aeb82013bf9e18a0c006138f7d3032dfb7.tar.gz |
#1040 / memory_maps() / sunos: fix unicode
Diffstat (limited to 'psutil/_psutil_sunos.c')
-rw-r--r-- | psutil/_psutil_sunos.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c index dc61ce1a..8e783d59 100644 --- a/psutil/_psutil_sunos.c +++ b/psutil/_psutil_sunos.c @@ -452,12 +452,12 @@ psutil_swap_mem(PyObject *self, PyObject *args) { static PyObject * psutil_users(PyObject *self, PyObject *args) { struct utmpx *ut; - PyObject *py_retlist = PyList_New(0); PyObject *py_tuple = NULL; PyObject *py_username = NULL; PyObject *py_tty = NULL; PyObject *py_hostname = NULL; PyObject *py_user_proc = NULL; + PyObject *py_retlist = PyList_New(0); if (py_retlist == NULL) return NULL; @@ -699,6 +699,7 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) { const char *procfs_path; PyObject *py_tuple = NULL; + PyObject *py_path = NULL; PyObject *py_retlist = PyList_New(0); if (py_retlist == NULL) @@ -777,12 +778,15 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) { } } + py_path = PyUnicode_DecodeFSDefault(name); + if (! py_path) + goto error; py_tuple = Py_BuildValue( - "iisslll", + "iisOlll", p->pr_vaddr, pr_addr_sz, perms, - name, + py_path, (long)p->pr_rss * p->pr_pagesize, (long)p->pr_anon * p->pr_pagesize, (long)p->pr_locked * p->pr_pagesize); @@ -790,6 +794,7 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) { goto error; if (PyList_Append(py_retlist, py_tuple)) goto error; + Py_DECREF(py_path); Py_DECREF(py_tuple); // increment pointer @@ -804,6 +809,7 @@ error: if (fd != -1) close(fd); Py_XDECREF(py_tuple); + Py_XDECREF(py_path); Py_DECREF(py_retlist); if (xmap != NULL) free(xmap); |