Kaynağa Gözat

remove some potential bugs

Julius Pfrommer 9 yıl önce
ebeveyn
işleme
a807a8853d

+ 5 - 5
src/server/ua_services_view.c

@@ -466,8 +466,8 @@ void Service_BrowseNext(UA_Server *server, UA_Session *session, const UA_BrowseN
        }
        response->resultsSize = size;
        for(size_t i = 0; i < size; i++) {
-           struct ContinuationPointEntry *cp;
-           LIST_FOREACH(cp, &session->continuationPoints, pointers) {
+           struct ContinuationPointEntry *cp, *temp;
+           LIST_FOREACH_SAFE(cp, &session->continuationPoints, pointers, temp) {
                if(UA_ByteString_equal(&cp->identifier, &request->continuationPoints[i])) {
                    Service_Browse_single(server, session, cp, UA_NULL, 0, &response->results[i]);
                    break;
@@ -485,9 +485,9 @@ void Service_BrowseNext(UA_Server *server, UA_Session *session, const UA_BrowseN
        }
        response->resultsSize = size;
        for(size_t i = 0; i < size; i++) {
-           struct ContinuationPointEntry *cp = UA_NULL;
-           LIST_FOREACH(cp, &session->continuationPoints, pointers) {
-               if(UA_ByteString_equal(&cp->identifier, &request->continuationPoints[i])) {
+           struct ContinuationPointEntry *cp, *temp;
+           LIST_FOREACH_SAFE(cp, &session->continuationPoints, pointers, temp) {
+               if(!UA_ByteString_equal(&cp->identifier, &request->continuationPoints[i])) {
                    removeCp(cp, session);
                    break;
                }

+ 3 - 3
src/server/ua_subscription_manager.c

@@ -47,9 +47,9 @@ void SubscriptionManager_init(UA_Session *session) {
 }
 
 void SubscriptionManager_deleteMembers(UA_Session *session, UA_Server *server) {
-    UA_SubscriptionManager *manager = &(session->subscriptionManager);
-    UA_Subscription *current;
-    while((current = LIST_FIRST(&manager->serverSubscriptions))) {
+    UA_SubscriptionManager *manager = &session->subscriptionManager;
+    UA_Subscription *current, *temp;
+    LIST_FOREACH_SAFE(current, &manager->serverSubscriptions, listEntry, temp) {
         LIST_REMOVE(current, listEntry);
         UA_Subscription_deleteMembers(current, server);
         UA_free(current);