Skip to content

Commit

Permalink
bpo-46280: Fix tracemalloc_copy_domain() (GH-30591)
Browse files Browse the repository at this point in the history
Test if tracemalloc_copy_traces() failed to allocated memory in
tracemalloc_copy_domain().
(cherry picked from commit 7c770d3)

Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
miss-islington and vstinner committed Jan 14, 2022
1 parent 537f16a commit ae6e255
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Modules/_tracemalloc.c
Expand Up @@ -1241,6 +1241,9 @@ tracemalloc_copy_domain(_Py_hashtable_t *domains,
_Py_hashtable_t *traces = (_Py_hashtable_t *)value;

_Py_hashtable_t *traces2 = tracemalloc_copy_traces(traces);
if (traces2 == NULL) {
return -1;
}
if (_Py_hashtable_set(domains2, TO_PTR(domain), traces2) < 0) {
_Py_hashtable_destroy(traces2);
return -1;
Expand Down

0 comments on commit ae6e255

Please sign in to comment.