]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46280: Fix tracemalloc_copy_domain() (GH-30591)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 14 Jan 2022 04:35:21 +0000 (20:35 -0800)
committerGitHub <noreply@github.com>
Fri, 14 Jan 2022 04:35:21 +0000 (20:35 -0800)
Test if tracemalloc_copy_traces() failed to allocated memory in
tracemalloc_copy_domain().
(cherry picked from commit 7c770d3350813a82a639fcb3babae0de2b87aaae)

Co-authored-by: Victor Stinner <vstinner@python.org>
Modules/_tracemalloc.c

index 90498fb7a7897d65e411f4ab26c102ffa8753fb2..ba0eb738abcbc5de23616db22d18dd24373dd964 100644 (file)
@@ -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;