瀏覽代碼

fix a potential NULL dereference

Julius Pfrommer 7 年之前
父節點
當前提交
43229ea721
共有 1 個文件被更改,包括 7 次插入1 次删除
  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))