mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 01:58:44 +08:00
[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.
This commit is contained in:
@@ -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)");
|
||||
|
||||
Reference in New Issue
Block a user