Skip to content

Commit 38141b3

Browse files
committed
[coverity] Fix 1566349 Resource leak
Move `ur_loader_config_handle_t` cleanup to the text fixture's `TearDown()`.
1 parent 19fdd60 commit 38141b3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/loader/loader_config/urLoaderConfigCreate.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55

66
#include "fixtures.hpp"
77

8-
struct LoaderConfigCreateTest : ::testing::Test {};
8+
struct LoaderConfigCreateTest : ::testing::Test {
9+
void TearDown() override {
10+
if (loaderConfig) {
11+
ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig));
12+
}
13+
}
914

10-
TEST_F(LoaderConfigCreateTest, Success) {
1115
ur_loader_config_handle_t loaderConfig = nullptr;
16+
};
17+
18+
TEST_F(LoaderConfigCreateTest, Success) {
1219
ASSERT_SUCCESS(urLoaderConfigCreate(&loaderConfig));
13-
ASSERT_SUCCESS(urLoaderConfigRelease(loaderConfig));
1420
}
1521

1622
TEST_F(LoaderConfigCreateTest, InvalidNullPointerLoaderConfig) {

0 commit comments

Comments
 (0)