Parcourir la source

fix a potential NULL dereference

Julius Pfrommer il y a 7 ans
Parent
commit
43229ea721
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7 1
      src/server/ua_services_nodemanagement.c

+ 7 - 1
src/server/ua_services_nodemanagement.c

@@ -334,9 +334,15 @@ instanceFindAggregateByBrowsename(UA_Server *server, UA_Session *session,
 
 static UA_Boolean
 mandatoryChild(UA_Server *server, UA_Session *session, const UA_NodeId *childNodeId) {
-    const UA_Node *child = UA_NodeStore_get(server->nodestore, childNodeId);
     const UA_NodeId mandatoryId = UA_NODEID_NUMERIC(0, UA_NS0ID_MODELLINGRULE_MANDATORY);
     const UA_NodeId hasModellingRuleId = UA_NODEID_NUMERIC(0, UA_NS0ID_HASMODELLINGRULE);
+
+    /* Get the child */
+    const UA_Node *child = UA_NodeStore_get(server->nodestore, childNodeId);
+    if(!child)
+        return false;
+
+    /* Look for the reference making the child mandatory */
     for(size_t i = 0; i < child->referencesSize; ++i) {
         UA_ReferenceNode *ref = &child->references[i];
         if(!UA_NodeId_equal(&hasModellingRuleId, &ref->referenceTypeId))