celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [celix] 04/05: Fixes memleak in pubsub topology manager
Date Mon, 26 Jul 2021 18:55:04 GMT
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/pubsub-interceptor-fix
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 0b04fde022c3cd9b681837d629fcb66d466be203
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
AuthorDate: Mon Jul 26 19:58:29 2021 +0200

    Fixes memleak in pubsub topology manager
---
 .../pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c b/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
index eca3796..fdeb20c 100644
--- a/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
+++ b/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
@@ -932,15 +932,13 @@ static void pstm_setupTopicSenders(pubsub_topology_manager_t *manager)
{
                 psa->matchPublisher(psa->handle, entry->bndId, entry->publisherFilter,
&topicProps, &score, &serSvcId,
                                     &protSvcId);
                 if (score > highestScore) {
-                    if (topicPropertiesForHighestMatch != NULL) {
-                        celix_properties_destroy(topicPropertiesForHighestMatch);
-                    }
+                    celix_properties_destroy(topicPropertiesForHighestMatch);
                     highestScore = score;
                     serializerSvcId = serSvcId;
                     protocolSvcId = protSvcId;
                     selectedPsaSvcId = svcId;
                     topicPropertiesForHighestMatch = topicProps;
-                } else if (topicProps != NULL) {
+                } else {
                     celix_properties_destroy(topicProps);
                 }
             }
@@ -968,6 +966,7 @@ static void pstm_setupTopicSenders(pubsub_topology_manager_t *manager)
{
                                       entry->scope,
                                       entry->topic,
                                       celix_filter_getFilterString(entry->publisherFilter));
+                celix_properties_destroy(topicPropertiesForHighestMatch);
             }
         }
     }
@@ -997,6 +996,8 @@ static void pstm_setupTopicSenders(pubsub_topology_manager_t *manager)
{
             celixThreadMutex_unlock(&manager->topicSenders.mutex);
         } else {
             celix_logHelper_warning(manager->loghelper, "Cannot setup TopicSender for
%s/%s\n", setupEntry->scope == NULL ? "(null)" : setupEntry->scope, setupEntry->topic);
+            celix_properties_destroy(setupEntry->topicProperties);
+            celix_properties_destroy(setupEntry->endpointResult);
         }
         free(setupEntry->scope);
         free(setupEntry->topic);

Mime
View raw message