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: check import attributes value types as strings · nodejs/node@2178007

File tree

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

‎src/module_wrap.cc‎

Copy file name to clipboardExpand all lines: src/module_wrap.cc
+15-2Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ using v8::UnboundModuleScript;
6363
using v8::Undefined;
6464
using v8::Value;
6565

66+
inline bool DataIsString(Local<Data> data) {
67+
return data->IsValue() && data.As<Value>()->IsString();
68+
}
69+
6670
void ModuleCacheKey::MemoryInfo(MemoryTracker* tracker) const {
6771
tracker->TrackField("specifier", specifier);
6872
tracker->TrackField("import_attributes", import_attributes);
@@ -83,6 +87,9 @@ ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
8387

8488
for (int i = 0; i < import_attributes->Length();
8589
i += elements_per_attribute) {
90+
DCHECK(DataIsString(import_attributes->Get(context, i)));
91+
DCHECK(DataIsString(import_attributes->Get(context, i + 1)));
92+
8693
Local<String> v8_key = import_attributes->Get(context, i).As<String>();
8794
Local<String> v8_value =
8895
import_attributes->Get(context, i + 1).As<String>();
@@ -488,9 +495,14 @@ static Local<Object> createImportAttributesContainer(
488495
LocalVector<Value> values(isolate, num_attributes);
489496

490497
for (int i = 0; i < raw_attributes->Length(); i += elements_per_attribute) {
498+
Local<Data> key = raw_attributes->Get(realm->context(), i);
499+
Local<Data> value = raw_attributes->Get(realm->context(), i + 1);
500+
DCHECK(DataIsString(key));
501+
DCHECK(DataIsString(value));
502+
491503
int idx = i / elements_per_attribute;
492-
names[idx] = raw_attributes->Get(realm->context(), i).As<Name>();
493-
values[idx] = raw_attributes->Get(realm->context(), i + 1).As<Value>();
504+
names[idx] = key.As<String>();
505+
values[idx] = value.As<String>();
494506
}
495507

496508
Local<Object> attributes = Object::New(
@@ -507,6 +519,7 @@ static Local<Array> createModuleRequestsContainer(
507519
LocalVector<Value> requests(isolate, raw_requests->Length());
508520

509521
for (int i = 0; i < raw_requests->Length(); i++) {
522+
DCHECK(raw_requests->Get(context, i)->IsModuleRequest());
510523
Local<ModuleRequest> module_request =
511524
raw_requests->Get(realm->context(), i).As<ModuleRequest>();
512525

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.