http://llvm.org/bugs/show_bug.cgi?id=11569
LLDBSwigPythonCallCommand crashes when a command script returns an object
Add more robustness to LLDBSwigPythonCallCommand. It should check whether the returned Python object
is a string, and only assign it as the error msg when the check holds.
Also add a regression test.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@146584 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/scripts/Python/python-wrapper.swig b/scripts/Python/python-wrapper.swig
index d68c1b9..787074e 100644
--- a/scripts/Python/python-wrapper.swig
+++ b/scripts/Python/python-wrapper.swig
@@ -645,9 +645,11 @@
err_msg.clear();
retval = true;
}
- else // return value is an error string
+ else
{
- err_msg.assign(PyString_AsString(pvalue));
+ // return value is an error string
+ if (PyString_CheckExact(pvalue))
+ err_msg.assign(PyString_AsString(pvalue));
retval = false;
}
Py_DECREF (pvalue);