| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 229f7f8 commit 584beaa
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1357,9 +1357,11 @@ StartupData SerializeNodeContextInternalFields(Local<Object> holder, | |||
| 1357 | 1357 | // To serialize the type field, save data in a EmbedderTypeInfo. | |
| 1358 | 1358 | if (index == BaseObject::kEmbedderType) { | |
| 1359 | 1359 | int size = sizeof(EmbedderTypeInfo); | |
| 1360 | - char* data = new char[size]; | ||
| 1361 | 1360 | // We need to use placement new because V8 calls delete[] on the returned | |
| 1362 | 1361 | // data. | |
| 1362 | + // The () syntax at the end would zero-initialize the block and make | ||
| 1363 | + // the padding reproducible. | ||
| 1364 | + char* data = new char[size](); | ||
| 1363 | 1365 | // TODO(joyeecheung): support cppgc objects. | |
| 1364 | 1366 | new (data) EmbedderTypeInfo(obj->type(), | |
| 1365 | 1367 | EmbedderTypeInfo::MemoryMode::kBaseObject); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,6 +47,7 @@ struct InternalFieldInfoBase { | |||
| 47 | 47 | std::is_same_v<InternalFieldInfoBase, T>, | |
| 48 | 48 | "Can only accept InternalFieldInfoBase subclasses"); | |
| 49 | 49 | void* buf = ::operator new[](sizeof(T)); | |
| 50 | + memset(buf, 0, sizeof(T)); // Make the padding reproducible. | ||
| 50 | 51 | T* result = new (buf) T; | |
| 51 | 52 | result->type = type; | |
| 52 | 53 | result->length = sizeof(T); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments