Explorar el Código

Fix memleak: release node from nodestore if variable type invalid

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4655

Credit to oss-fuzz
Stefan Profanter hace 7 años
padre
commit
9ae4714704
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      src/server/ua_services_nodemanagement.c

+ 3 - 1
src/server/ua_services_nodemanagement.c

@@ -220,8 +220,10 @@ useVariableTypeAttributes(UA_Server *server, UA_Session *session,
 
     const UA_VariableTypeNode *vt = (const UA_VariableTypeNode*)
         UA_Nodestore_get(server, typeDefinition);
-    if(!vt || vt->nodeClass != UA_NODECLASS_VARIABLETYPE)
+    if(!vt || vt->nodeClass != UA_NODECLASS_VARIABLETYPE) {
+        UA_Nodestore_release(server, (const UA_Node*)vt);
         return UA_STATUSCODE_BADTYPEMISMATCH;
+    }
         
     /* If no value is set, see if the vt provides one and copy it. This needs to
      * be done before copying the datatype from the vt, as setting the datatype