Browse Source

View Basic is all green

Julius Pfrommer 10 years ago
parent
commit
f68589bb8a
1 changed files with 10 additions and 7 deletions
  1. 10 7
      src/server/ua_services_view.c

+ 10 - 7
src/server/ua_services_view.c

@@ -160,15 +160,8 @@ static void browse(UA_NodeStore *ns, struct ContinuationPointEntry **cp, const U
     
     size_t relevant_refs_size = 0;
     UA_NodeId *relevant_refs = UA_NULL;
-    // what are the relevant references?
     UA_Boolean all_refs = UA_NodeId_isNull(&descr->referenceTypeId);
 
-    //check if reference type id exists
-    if(!all_refs && UA_NodeStore_get(ns, &descr->referenceTypeId) == UA_NULL) {
-        result->statusCode = UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
-        return;
-    }
-
     if(!all_refs) {
         if(descr->includeSubtypes) {
             result->statusCode = findsubtypes(ns, &descr->referenceTypeId, &relevant_refs,
@@ -176,6 +169,16 @@ static void browse(UA_NodeStore *ns, struct ContinuationPointEntry **cp, const U
             if(result->statusCode != UA_STATUSCODE_GOOD)
                 return;
         } else {
+            const UA_Node *rootRef = UA_NodeStore_get(ns, &descr->referenceTypeId);
+            if(!rootRef) {
+                result->statusCode = UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
+                return;
+            } else if(rootRef->nodeClass != UA_NODECLASS_REFERENCETYPE) {
+                UA_NodeStore_release(rootRef);
+                result->statusCode = UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
+                return;
+            }
+            UA_NodeStore_release(rootRef);
             relevant_refs = (UA_NodeId*)(uintptr_t)&descr->referenceTypeId;
             relevant_refs_size = 1;
         }