Parcourir la source

Fix "Null pointer passed as argument 2, which is declared to never be null"

Stefan Profanter il y a 6 ans
Parent
commit
338900b865
1 fichiers modifiés avec 5 ajouts et 3 suppressions
  1. 5 3
      arch/ua_network_tcp.c

+ 5 - 3
arch/ua_network_tcp.c

@@ -144,9 +144,11 @@ connection_recv(UA_Connection *connection, UA_ByteString *response,
     }
 
     /* Preprend the last incompleteChunk into the buffer */
-    memcpy(response->data, connection->incompleteChunk.data,
-           connection->incompleteChunk.length);
-    UA_ByteString_deleteMembers(&connection->incompleteChunk);
+    if (connection->incompleteChunk.length > 0) {
+        memcpy(response->data, connection->incompleteChunk.data,
+               connection->incompleteChunk.length);
+        UA_ByteString_deleteMembers(&connection->incompleteChunk);
+    }
 
     /* Set the length of the received buffer */
     response->length = offset + (size_t)ret;