Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: components/tracing/core/proto_zero_message_handle.cc

Issue 2240043004: Tracing V2: Fully-functional plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix use after free in tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/tracing/core/proto_zero_message_handle.h" 5 #include "components/tracing/core/proto_zero_message_handle.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/tracing/core/proto_zero_message.h" 8 #include "components/tracing/core/proto_zero_message.h"
9 9
10 namespace tracing { 10 namespace tracing {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // If the current handle was pointing to a message and is being reset to a new 50 // If the current handle was pointing to a message and is being reset to a new
51 // one, finalize the old message. 51 // one, finalize the old message.
52 FinalizeMessageIfSet(message_); 52 FinalizeMessageIfSet(message_);
53 53
54 // In theory other->message_ could be nullptr, if |other| is a handle that has 54 // In theory other->message_ could be nullptr, if |other| is a handle that has
55 // been std::move-d (and hence empty). There isn't a legitimate use case for 55 // been std::move-d (and hence empty). There isn't a legitimate use case for
56 // doing so, though. Therefore this case is deliberately ignored (if hit, it 56 // doing so, though. Therefore this case is deliberately ignored (if hit, it
57 // will manifest as a segfault when dereferencing |message_| below) to avoid a 57 // will manifest as a segfault when dereferencing |message_| below) to avoid a
58 // useless null-check. 58 // useless null-check.
59 message_ = other->message_; 59 message_ = other->message_;
60 sealed_fields_ = std::move(other->sealed_fields_);
60 other->message_ = nullptr; 61 other->message_ = nullptr;
61 #if DCHECK_IS_ON() 62 #if DCHECK_IS_ON()
62 message_->set_handle(this); 63 message_->set_handle(this);
63 #endif 64 #endif
64 } 65 }
65 66
66 } // namespace v2 67 } // namespace v2
67 } // namespace tracing 68 } // namespace tracing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698