GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: zero-initialize data that are copied into the snapshot · nodejs/node@584beaa

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_snapshotable.cc
    • node_snapshotable.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_snapshotable.cc‎

Copy file name to clipboardExpand all lines: src/node_snapshotable.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,9 +1357,11 @@ StartupData SerializeNodeContextInternalFields(Local<Object> holder,
13571357
// To serialize the type field, save data in a EmbedderTypeInfo.
13581358
if (index == BaseObject::kEmbedderType) {
13591359
int size = sizeof(EmbedderTypeInfo);
1360-
char* data = new char[size];
13611360
// We need to use placement new because V8 calls delete[] on the returned
13621361
// data.
1362+
// The () syntax at the end would zero-initialize the block and make
1363+
// the padding reproducible.
1364+
char* data = new char[size]();
13631365
// TODO(joyeecheung): support cppgc objects.
13641366
new (data) EmbedderTypeInfo(obj->type(),
13651367
EmbedderTypeInfo::MemoryMode::kBaseObject);
Collapse file

‎src/node_snapshotable.h‎

Copy file name to clipboardExpand all lines: src/node_snapshotable.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct InternalFieldInfoBase {
4747
std::is_same_v<InternalFieldInfoBase, T>,
4848
"Can only accept InternalFieldInfoBase subclasses");
4949
void* buf = ::operator new[](sizeof(T));
50+
memset(buf, 0, sizeof(T)); // Make the padding reproducible.
5051
T* result = new (buf) T;
5152
result->type = type;
5253
result->length = sizeof(T);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.