celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject svn commit: r1306527 - in /incubator/celix/trunk/framework/private/src: service_registration.c service_tracker.c
Date Wed, 28 Mar 2012 18:33:10 GMT
Author: pnoltes
Date: Wed Mar 28 18:33:10 2012
New Revision: 1306527

URL: http://svn.apache.org/viewvc?rev=1306527&view=rev
Log:
CELIX-30, CELIX-31, CELIX-32: Removed memory leaks and fixed buffer overflow bug.

Modified:
    incubator/celix/trunk/framework/private/src/service_registration.c
    incubator/celix/trunk/framework/private/src/service_tracker.c

Modified: incubator/celix/trunk/framework/private/src/service_registration.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registration.c?rev=1306527&r1=1306526&r2=1306527&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Wed Mar 28 18:33:10
2012
@@ -72,7 +72,7 @@ celix_status_t serviceRegistration_creat
     *registration = (SERVICE_REGISTRATION) apr_palloc(pool, sizeof(**registration));
     (*registration)->isServiceFactory = isFactory;
     (*registration)->registry = registry;
-    (*registration)->className = serviceName;
+    (*registration)->className = apr_pstrdup(pool,serviceName);
     (*registration)->bundle = bundle;
     (*registration)->references = NULL;
     arrayList_create(pool, &(*registration)->references);

Modified: incubator/celix/trunk/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_tracker.c?rev=1306527&r1=1306526&r2=1306527&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Wed Mar 28 18:33:10 2012
@@ -61,15 +61,10 @@ celix_status_t serviceTracker_create(apr
 	} else {
 		if (status == CELIX_SUCCESS) {
 			int len = strlen(service) + strlen(OBJECTCLASS) + 4;
-			char *filter = apr_palloc(pool, sizeof(char) * len);
+			char *filter = apr_pstrcat(pool, "(", OBJECTCLASS, "=", service, ")", NULL);
 			if (filter == NULL) {
 				status = CELIX_ENOMEM;
 			} else {
-				strcpy(filter, "(");
-				strcat(filter, OBJECTCLASS);
-				strcat(filter, "=");
-				strcat(filter, service);
-				strcat(filter, ")\0");
 				serviceTracker_createWithFilter(pool, context, filter, customizer, tracker);
 			}
 		}
@@ -89,7 +84,7 @@ celix_status_t serviceTracker_createWith
 		apr_pool_pre_cleanup_register(pool, *tracker, serviceTracker_destroy);
 
 		(*tracker)->context = context;
-		(*tracker)->filter = filter;
+		(*tracker)->filter = apr_pstrdup(pool,filter);
 
 		(*tracker)->pool = pool;
 		(*tracker)->tracker = *tracker;



Mime
View raw message