From 181a30867ad83a50e3d09a01dbb9a62a7d2824aa Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Tue, 12 Jun 2018 07:00:22 +0200 Subject: typewrappers: Fix libvirt_charPtrUnwrap to set an exception if it fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the function fails it should always set an exception. Reviewed-by: Ján Tomko Signed-off-by: Pavel Hrdina --- typewrappers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'typewrappers.c') diff --git a/typewrappers.c b/typewrappers.c index 01ee310..99a8fb8 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -384,8 +384,11 @@ libvirt_charPtrUnwrap(PyObject *obj, #else ret = PyString_AsString(obj); #endif - if (ret) + if (ret) { *str = strdup(ret); + if (!*str) + PyErr_NoMemory(); + } #if PY_MAJOR_VERSION > 2 Py_DECREF(bytes); #endif -- cgit v1.2.1