diff options
author | Armin Rigo <arigo@tunes.org> | 2020-02-06 11:35:36 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-02-06 11:35:36 +0100 |
commit | 50948fb657d6d983142f834064bffc8289b698f5 (patch) | |
tree | b05a48ae634ffbb3ad612ad1be7138de5d14f76d | |
parent | 852666064108f597d0c17d8ef5fa90e8b091bf32 (diff) | |
download | cffi-50948fb657d6d983142f834064bffc8289b698f5.tar.gz |
#442: memory leak in getwinerror() in py3
-rw-r--r-- | c/misc_win32.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/c/misc_win32.h b/c/misc_win32.h index 07b76c1..156cf5d 100644 --- a/c/misc_win32.h +++ b/c/misc_win32.h @@ -124,8 +124,10 @@ static PyObject *b_getwinerror(PyObject *self, PyObject *args, PyObject *kwds) s_buf[--len] = L'\0'; message = PyUnicode_FromWideChar(s_buf, len); } - if (message != NULL) + if (message != NULL) { v = Py_BuildValue("(iO)", err, message); + Py_DECREF(message); + } else v = NULL; LocalFree(s_buf); @@ -168,7 +170,6 @@ static PyObject *b_getwinerror(PyObject *self, PyObject *args, PyObject *kwds) /* Only seen this in out of mem situations */ sprintf(s_small_buf, "Windows Error 0x%X", err); s = s_small_buf; - s_buf = NULL; } else { s = s_buf; /* remove trailing cr/lf and dots */ |