[python PATCH 2/4] typewrappers: Fix libvirt_charPtrUnwrap to set an exception if it fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the function fails it should always set an exception.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 typewrappers.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux