@@ -271,9 +271,6 @@ LLDBSwigPythonCreateScriptedThreadPlan
271271 if (python_class_name == NULL || python_class_name[0 ] == ' \0 ' || !session_dictionary_name)
272272 Py_RETURN_NONE;
273273
274- // I do not want the SBThreadPlan to be deallocated when going out of scope because python
275- // has ownership of it and will manage memory for this object by itself
276- lldb::SBThreadPlan *tp_value = new lldb::SBThreadPlan (thread_plan_sp);
277274
278275 PyErr_Cleaner py_err_cleaner (true );
279276
@@ -286,7 +283,10 @@ LLDBSwigPythonCreateScriptedThreadPlan
286283 return nullptr ;
287284 }
288285
289- PythonObject tp_arg (PyRefType::Owned, SBTypeToSWIGWrapper (tp_value));
286+ // I do not want the SBThreadPlan to be deallocated when going out of scope
287+ // because python has ownership of it and will manage memory for this
288+ // object by itself
289+ PythonObject tp_arg (PyRefType::Owned, SBTypeToSWIGWrapper (new lldb::SBThreadPlan (thread_plan_sp)));
290290
291291 if (!tp_arg.IsAllocated ())
292292 Py_RETURN_NONE;
@@ -312,8 +312,7 @@ LLDBSwigPythonCreateScriptedThreadPlan
312312 }
313313 result = pfunc (tp_arg, dict);
314314 } else if (arg_info.get ().max_positional_args >= 3 ) {
315- lldb::SBStructuredData *args_value = new lldb::SBStructuredData (args_impl);
316- PythonObject args_arg (PyRefType::Owned, SBTypeToSWIGWrapper (args_value));
315+ PythonObject args_arg (PyRefType::Owned, SBTypeToSWIGWrapper (new lldb::SBStructuredData (args_impl)));
317316 result = pfunc (tp_arg, args_arg, dict);
318317 } else {
319318 error_string.assign (" wrong number of arguments in __init__, should be 2 or 3 (not including self)" );
0 commit comments