| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7d66752 commit b9dfdfe
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,7 +205,11 @@ class ContextifyContext { | |||
| 205 | 205 | ||
| 206 | 206 | Local<Context> ctx = Context::New(env->isolate(), nullptr, object_template); | |
| 207 | 207 | ||
| 208 | - CHECK(!ctx.IsEmpty()); | ||
| 208 | + if (ctx.IsEmpty()) { | ||
| 209 | + env->ThrowError("Could not instantiate context"); | ||
| 210 | + return Local<Context>(); | ||
| 211 | + } | ||
| 212 | + | ||
| 209 | 213 | ctx->SetSecurityToken(env->context()->GetSecurityToken()); | |
| 210 | 214 | ||
| 211 | 215 | // We need to tie the lifetime of the sandbox object with the lifetime of | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const vm = require('vm'); | ||
| 5 | + | ||
| 6 | + function a() { | ||
| 7 | + try { | ||
| 8 | + return a(); | ||
| 9 | + } catch (e) { | ||
| 10 | + // Throw an exception as near to the recursion-based RangeError as possible. | ||
| 11 | + return vm.runInThisContext('() => 42')(); | ||
| 12 | + } | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + assert.strictEqual(a(), 42); | ||
| 16 | + | ||
| 17 | + function b() { | ||
| 18 | + try { | ||
| 19 | + return b(); | ||
| 20 | + } catch (e) { | ||
| 21 | + // This writes a lot of noise to stderr, but it still works. | ||
| 22 | + return vm.runInNewContext('() => 42')(); | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + assert.strictEqual(b(), 42); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments