GeezerVison is showing github.com — src: make ModifyCodeGenerationFromStrings more robust · nodejs/node@1e7d101
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_errors.cc +11-1Lines changed: 11 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -608,8 +608,18 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( |
608 | 608 | bool is_code_like) { |
609 | 609 | HandleScope scope(context->GetIsolate()); |
610 | 610 |
|
| 611 | + if (context->GetNumberOfEmbedderDataFields() <= |
| 612 | + ContextEmbedderIndex::kAllowCodeGenerationFromStrings) { |
| 613 | + // The context is not (yet) configured by Node.js for this. We don't |
| 614 | + // have enough information to make a decision, just allow it which is |
| 615 | + // the default. |
| 616 | + return {true, {}}; |
| 617 | + } |
611 | 618 | Environment* env = Environment::GetCurrent(context); |
612 | | - if (env->source_maps_enabled()) { |
| 619 | + if (env == nullptr) { |
| 620 | + return {true, {}}; |
| 621 | + } |
| 622 | + if (env->source_maps_enabled() && env->can_call_into_js()) { |
613 | 623 | // We do not expect the maybe_cache_generated_source_map to throw any more |
614 | 624 | // exceptions. If it does, just ignore it. |
615 | 625 | errors::TryCatchScope try_catch(env); |
|