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

Unified Diff: src/snapshot/serializer-common.h

Issue 2781993005: Protect SerializedData from copying. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/snapshot/code-serializer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/serializer-common.h
diff --git a/src/snapshot/serializer-common.h b/src/snapshot/serializer-common.h
index 02f97628b5a080b9e7683744b20b24b421127afe..c357df8743e426504d3730d96c447c92336dd929 100644
--- a/src/snapshot/serializer-common.h
+++ b/src/snapshot/serializer-common.h
@@ -239,11 +239,19 @@ class SerializedData {
SerializedData(byte* data, int size)
: data_(data), size_(size), owns_data_(false) {}
SerializedData() : data_(NULL), size_(0), owns_data_(false) {}
+ SerializedData(SerializedData&& other)
+ : data_(other.data_), size_(other.size_), owns_data_(other.owns_data_) {
+ // Ensure |other| will not attempt to destroy our data in destructor.
+ other.owns_data_ = false;
+ }
~SerializedData() {
if (owns_data_) DeleteArray<byte>(data_);
}
+ SerializedData(const SerializedData&) = delete;
+ const SerializedData& operator=(const SerializedData&) = delete;
+
Yang 2017/03/29 17:06:59 We have a macro called DISALLOW_COPY_AND_ASSIGN or
Slava Chigrin 2017/03/30 09:40:06 Done. Thanks - didn't notice that V8 also have thi
uint32_t GetMagicNumber() const { return GetHeaderValue(kMagicNumberOffset); }
uint32_t GetExtraReferences() const {
return GetHeaderValue(kExtraExternalReferencesOffset);
« no previous file with comments | « src/snapshot/code-serializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698