celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [27/50] celix git commit: CELIX-347: Remove several mem leaks in dependency manager.
Date Mon, 11 Apr 2016 10:54:54 GMT
CELIX-347: Remove several mem leaks in dependency manager.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/88a7da2d
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/88a7da2d
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/88a7da2d

Branch: refs/heads/release/celix-2.0.0
Commit: 88a7da2d88152c005af35b45e04eeecf68128ab6
Parents: 492c214
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Wed Feb 10 08:41:35 2016 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Wed Feb 10 08:41:35 2016 +0100

----------------------------------------------------------------------
 .../private/src/dm_service_dependency.c           | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/88a7da2d/dependency_manager/private/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_service_dependency.c b/dependency_manager/private/src/dm_service_dependency.c
index a92bfbf..11ea28b 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -163,7 +163,7 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
         }
 
         if (serviceVersionRange != NULL) {
-            version_range_pt versionRange;
+            version_range_pt versionRange = NULL;
 
             if (versionRange_parse(serviceVersionRange, &versionRange) == CELIX_SUCCESS)
{
                 version_pt lowVersion = NULL;
@@ -172,7 +172,7 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
                 if ((versionRange_getHighVersion(versionRange, &highVersion) == CELIX_SUCCESS)
&& (highVersion != NULL)) {
                     bool isHighInclusive;
                     char* highOperator;
-                    char* highVersionStr;
+                    char* highVersionStr = NULL;
 
                     versionRange_isHighInclusive(versionRange, &isHighInclusive);
                     version_toString(highVersion, &highVersionStr);
@@ -183,12 +183,16 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt
dependency,
                     char serviceVersionFilter[len];
                     snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION,
highOperator, highVersionStr);
                     arrayList_add(filterElements, strdup(serviceVersionFilter));
+
+                    if(highVersionStr!=NULL){
+                    	free(highVersionStr);
+                    }
                 }
 
                 if ((versionRange_getLowVersion(versionRange, &lowVersion) == CELIX_SUCCESS)
&& (lowVersion != NULL)) {
                     bool isLowInclusive;
                     char* lowOperator;
-                    char* lowVersionStr;
+                    char* lowVersionStr = NULL;
 
                     versionRange_isLowInclusive(versionRange, &isLowInclusive);
                     version_toString(lowVersion, &lowVersionStr);
@@ -199,8 +203,16 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt
dependency,
                     char serviceVersionFilter[len];
                     snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION,
lowOperator, lowVersionStr);
                     arrayList_add(filterElements, strdup(serviceVersionFilter));
+
+                    if(lowVersionStr!=NULL){
+                    	free(lowVersionStr);
+                    }
                 }
             }
+
+            if(versionRange!=NULL){
+            	versionRange_destroy(versionRange);
+            }
         }
 
         if (filter != NULL) {


Mime
View raw message