Skip to content

Commit

Permalink
Merge pull request #788 from xuzhenbao/earpm_unit_test_bugfix
Browse files Browse the repository at this point in the history
Resolve stack-use-after in unit test
  • Loading branch information
xuzhenbao authored Jan 14, 2025
2 parents 22effe4 + 127eecb commit 5c3b672
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CelixEarpmIntegrationTestSuite : public ::testing::Test {
std::future<void> receivedEventFuture = receivedEventPromise.get_future();
auto props = celix_properties_create();
celix_properties_set(props, CELIX_EVENT_TOPIC, "testEvent");
static celix_event_handler_service_t handler = {
celix_event_handler_service_t handler = {
.handle = &receivedEventPromise,
.handleEvent = [](void* handle, const char* topic, const celix_properties_t* properties) {
EXPECT_STREQ("testEvent", topic);
Expand Down Expand Up @@ -115,6 +115,7 @@ class CelixEarpmIntegrationTestSuite : public ::testing::Test {
useOpts.filter.serviceName = CELIX_EVENT_ADMIN_SERVICE_NAME;
useOpts.filter.versionRange = CELIX_EVENT_ADMIN_SERVICE_USE_RANGE;
useOpts.callbackHandle = &handle;
useOpts.waitTimeoutInSeconds = 30;
useOpts.use = [](void* handle, void* svc) {
celix_event_admin_service_t *eventAdmin = static_cast<celix_event_admin_service_t *>(svc);
celix_autoptr(celix_properties_t) props = celix_properties_create();
Expand All @@ -136,7 +137,7 @@ class CelixEarpmIntegrationTestSuite : public ::testing::Test {
EXPECT_TRUE(tryCount >= 0);
};
auto found= celix_bundleContext_useServiceWithOptions(publisherCtx.get(), &useOpts);
ASSERT_TRUE(found);
EXPECT_TRUE(found);

celix_bundleContext_unregisterService(subscriberCtx.get(), handlerServiceId);
}
Expand Down

0 comments on commit 5c3b672

Please sign in to comment.