Skip to content

Commit

Permalink
Merge branch '2.11' into backport-10681-to-2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrenner committed Sep 20, 2024
2 parents f810426 + 44043c2 commit cf38dc8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ddtrace/appsec/_iast/_taint_tracking/_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ PYBIND11_MODULE(_native, m)
}

initializer = make_unique<Initializer>();
// Create an atexit callback to clean up the Initializer before the interpreter finishes
auto atexit_register = py::module_::import("atexit").attr("register");
atexit_register(py::cpp_function([]() {
initializer->reset_context();
initializer.reset();
}));
initializer->create_context();

m.doc() = "Native Python module";
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/initializer-atexit-4c10671e585ac3e7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Code Security: ensure the ``Initializer`` object is always reset and freed before the Python runtime.

0 comments on commit cf38dc8

Please sign in to comment.