diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-03-05 18:57:06 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-03-05 18:57:06 +0000 |
commit | 9e926fd7d88afcad9ea6abcde9c826ebe432f485 (patch) | |
tree | d989afaa4dc414ae40982d6ba72cfe2048d90224 /_obnammodule.c | |
parent | 93eb916b7315f5f52e8fa5e169916d4c75707a5e (diff) | |
download | obnam-9e926fd7d88afcad9ea6abcde9c826ebe432f485.tar.gz |
Catch and handle malloc errors in _obnammodule.py
Diffstat (limited to '_obnammodule.c')
-rw-r--r-- | _obnammodule.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/_obnammodule.c b/_obnammodule.c index 75cf3960..94dea0fc 100644 --- a/_obnammodule.c +++ b/_obnammodule.c @@ -183,6 +183,10 @@ llistxattr_wrapper(PyObject *self, PyObject *args) #ifdef __FreeBSD__ bufsize = extattr_list_link(filename, EXTATTR_NAMESPACE_USER, NULL, 0); buf = malloc(bufsize); + if (buf == NULL) { + Py_INCREF(Py_None); + return Py_None; + } n = extattr_list_link(filename, EXTATTR_NAMESPACE_USER, buf, bufsize); if (n >= 0) { /* Convert from length-prefixed BSD style to '\0'-suffixed @@ -205,6 +209,10 @@ llistxattr_wrapper(PyObject *self, PyObject *args) do { bufsize += 1024; buf = malloc(bufsize); + if (buf == NULL) { + Py_INCREF(Py_None); + return Py_None; + } n = llistxattr(filename, buf, bufsize); if (n >= 0) @@ -234,6 +242,10 @@ lgetxattr_wrapper(PyObject *self, PyObject *args) do { bufsize += 1024; char *buf = malloc(bufsize); + if (buf == NULL) { + Py_INCREF(Py_None); + return Py_None; + } #ifdef __FreeBSD__ int n = extattr_get_link(filename, EXTATTR_NAMESPACE_USER, attrname, buf, bufsize); #else |