Parcourir la source

Copy value before freeing it

Stefan Profanter il y a 8 ans
Parent
commit
d4c4c4522a
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      src/client/ua_client_highlevel.c

+ 6 - 1
src/client/ua_client_highlevel.c

@@ -434,7 +434,12 @@ UA_Client_readArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId
         goto cleanup;
         goto cleanup;
     }
     }
 
 
-    *outArrayDimensions = res->value.data;
+    *outArrayDimensions = UA_Array_new(res->value.arrayLength, &UA_TYPES[UA_TYPES_UINT32]);
+    retval = UA_Array_copy(res->value.data, res->value.arrayLength, (void **)&(*outArrayDimensions), &UA_TYPES[UA_TYPES_UINT32]);
+    if (retval != UA_STATUSCODE_GOOD) {
+        UA_free(res->value.data);
+        goto cleanup;
+    }
     *outArrayDimensionsSize = res->value.arrayLength;
     *outArrayDimensionsSize = res->value.arrayLength;
     UA_free(res->value.data);
     UA_free(res->value.data);
     res->value.data = NULL;
     res->value.data = NULL;