瀏覽代碼

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

Stefan Profanter 6 年之前
父節點
當前提交
338900b865
共有 1 個文件被更改,包括 5 次插入3 次删除
  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;