Skip to content

Commit 3d20650

Browse files
committed
[PyROOT] Destroy STL string objects in StringExecutor
::operator delete only frees the memory that was previously allocated in Cppyy::CallO, but does not call the destructor of the std::string. Make sure that is done using keyword delete.
1 parent 78298a1 commit 3d20650

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bindings/pyroot/cppyy/CPyCppyy/src/Executors.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ PyObject* CPyCppyy::STLStringExecutor::Execute(
566566

567567
PyObject* pyresult =
568568
CPyCppyy_PyText_FromStringAndSize(result->c_str(), result->size());
569-
::operator delete(result); // calls Cppyy::CallO which calls ::operator new
569+
delete result; // Cppyy::CallO allocates and constructs a string, so it must be properly destroyed
570570

571571
return pyresult;
572572
}
@@ -584,7 +584,7 @@ PyObject* CPyCppyy::STLWStringExecutor::Execute(
584584
}
585585

586586
PyObject* pyresult = PyUnicode_FromWideChar(result->c_str(), result->size());
587-
::operator delete(result); // calls Cppyy::CallO which calls ::operator new
587+
delete result; // Cppyy::CallO allocates and constructs a string, so it must be properly destroyed
588588

589589
return pyresult;
590590
}

0 commit comments

Comments
 (0)