Mesa (staging/20.2): util: Fix memory leaks in unit test.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 18 17:43:32 UTC 2020


Module: Mesa
Branch: staging/20.2
Commit: 11edf2e35774499e2baf2e2c353964801506f967
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=11edf2e35774499e2baf2e2c353964801506f967

Author: Vinson Lee <vlee at freedesktop.org>
Date:   Sat Aug  8 21:26:12 2020 -0700

util: Fix memory leaks in unit test.

Fix warnings reported by Coverity Scan.

Resource leak (RESOURCE_LEAK)
leaked_storage: Variable bt1 going out of scope leaks the storage
it points to.
leaked_storage: Variable bt2 going out of scope leaks the storage
it points to.

Fixes: d0d14f3f6481 ("util: Add unit test for stack backtrace caputure")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6246>
(cherry picked from commit 96cfc684e63238a7aeabc8893fb04fe5f3781a66)

---

 .pick_status.json               | 2 +-
 src/util/u_debug_stack_test.cpp | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index b99a9d46c74..ad8dd31bece 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -310,7 +310,7 @@
         "description": "util: Fix memory leaks in unit test.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "d0d14f3f6481e015b4413fa0487164b76fe45296"
     },
diff --git a/src/util/u_debug_stack_test.cpp b/src/util/u_debug_stack_test.cpp
index b5f8ea4ba38..6add3e989b2 100644
--- a/src/util/u_debug_stack_test.cpp
+++ b/src/util/u_debug_stack_test.cpp
@@ -106,6 +106,9 @@ TEST(u_debug_stack_test, capture_not_overwritten)
    if (size > 0) {
       EXPECT_STRNE(bt1, bt2);
    }
+
+   free(bt1);
+   free(bt2);
 }
 
 #endif



More information about the mesa-commit mailing list