[Lldb-commits] [lldb] b79dff0 - [lldb] Make sure we don't leak SBThreadPlan pointer (NFCI)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 20 16:59:46 PDT 2020
Author: Jonas Devlieghere
Date: 2020-07-20T16:58:06-07:00
New Revision: b79dff02795074ca5a4937fc1c93cf0dc7b8d943
URL: https://github.com/llvm/llvm-project/commit/b79dff02795074ca5a4937fc1c93cf0dc7b8d943
DIFF: https://github.com/llvm/llvm-project/commit/b79dff02795074ca5a4937fc1c93cf0dc7b8d943.diff
LOG: [lldb] Make sure we don't leak SBThreadPlan pointer (NFCI)
Make sure we don't accidentally leak the SBThreadPlan pointer when we
return before handing it off to Python to manage its lifetime.
Added:
Modified:
lldb/bindings/python/python-wrapper.swig
Removed:
################################################################################
diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig
index f9e89373fe25..516590ed5771 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -271,9 +271,6 @@ LLDBSwigPythonCreateScriptedThreadPlan
if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
Py_RETURN_NONE;
- // I do not want the SBThreadPlan to be deallocated when going out of scope because python
- // has ownership of it and will manage memory for this object by itself
- lldb::SBThreadPlan *tp_value = new lldb::SBThreadPlan(thread_plan_sp);
PyErr_Cleaner py_err_cleaner(true);
@@ -286,7 +283,10 @@ LLDBSwigPythonCreateScriptedThreadPlan
return nullptr;
}
- PythonObject tp_arg(PyRefType::Owned, SBTypeToSWIGWrapper(tp_value));
+ // I do not want the SBThreadPlan to be deallocated when going out of scope
+ // because python has ownership of it and will manage memory for this
+ // object by itself
+ PythonObject tp_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new lldb::SBThreadPlan(thread_plan_sp)));
if (!tp_arg.IsAllocated())
Py_RETURN_NONE;
@@ -312,8 +312,7 @@ LLDBSwigPythonCreateScriptedThreadPlan
}
result = pfunc(tp_arg, dict);
} else if (arg_info.get().max_positional_args >= 3) {
- lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
- PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(args_value));
+ PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new lldb::SBStructuredData(args_impl)));
result = pfunc(tp_arg, args_arg, dict);
} else {
error_string.assign("wrong number of arguments in __init__, should be 2 or 3 (not including self)");
More information about the lldb-commits
mailing list