franz1981 commented on a change in pull request #543: DISPATCH-1390 - 
qd_buffer_list_clone is copying too much data
URL: https://github.com/apache/qpid-dispatch/pull/543#discussion_r317708895
 
 

 ##########
 File path: src/buffer.c
 ##########
 @@ -65,19 +65,17 @@ unsigned int qd_buffer_list_clone(qd_buffer_list_t *dst, 
const qd_buffer_list_t
     qd_buffer_t *buf = DEQ_HEAD(*src);
     while (buf) {
         size_t to_copy = qd_buffer_size(buf);
-        unsigned char *src = qd_buffer_base(buf);
+        unsigned char *src_base = qd_buffer_base(buf);
         len += to_copy;
         while (to_copy) {
-            qd_buffer_t *newbuf = qd_buffer();
-            size_t count = qd_buffer_capacity(newbuf);
-            // default buffer capacity may have changed,
-            // so don't assume it will fit:
-            if (count > to_copy) count = to_copy;
-            memcpy(qd_buffer_cursor(newbuf), src, count);
-            qd_buffer_insert(newbuf, count);
+            qd_buffer_t *const restrict newbuf = qd_buffer();
+            const size_t new_capacity = qd_buffer_capacity(newbuf);
+            const size_t copy_size = to_copy < new_capacity ? to_copy : 
new_capacity;
 
 Review comment:
   indeed if you run the new change on the test on the old code will fail

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to