You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by "acelyc111 (via GitHub)" <gi...@apache.org> on 2024/08/09 11:12:15 UTC

Re: [PR] fix(duplication): fix heap-use-after-free error by mutation_batch::add_mutation_if_valid [incubator-pegasus]

acelyc111 commented on code in PR #2088:
URL: https://github.com/apache/incubator-pegasus/pull/2088#discussion_r1711274616


##########
src/replica/duplication/mutation_batch.cpp:
##########
@@ -196,10 +196,10 @@ void mutation_batch::add_mutation_if_valid(mutation_ptr &mu, decree start_decree
         }
 
         blob bb;
-        if (update.data.buffer() != nullptr) {
+        if (update.data.buffer()) {
+            // ATTENTION: instead of copy, move could optimize the performance. However, this
+            // would nullify the elements of mu->data.updates.
             bb = std::move(update.data);
-        } else {
-            bb = blob::create_from_bytes(update.data.data(), update.data.length());
         }

Review Comment:
   While it's possible the `_holder` is nullptr and `_data` has a valid data pointer, so it's needed to process the latter case.



-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org