Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
Merge commit 'b9dfdfe1d32fe765c1351b784830ebec3800cc07' into v4.5.0-p…
Browse files Browse the repository at this point in the history
…roposal-port
  • Loading branch information
richardlau committed Jul 14, 2016
2 parents 860020b + b9dfdfe commit db4b8f2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ ifdef QUICKCHECK
endif

ifdef ENABLE_V8_TAP
TAP_V8 := --junitout v8-tap.xml
TAP_V8_INTL := --junitout v8-intl-tap.xml
TAP_V8_BENCHMARKS := --junitout v8-benchmarks-tap.xml
TAP_V8 := --junitout $(PWD)/v8-tap.xml
TAP_V8_INTL := --junitout $(PWD)/v8-intl-tap.xml
TAP_V8_BENCHMARKS := --junitout $(PWD)/v8-benchmarks-tap.xml
endif

ifdef DISABLE_V8_I18N
Expand Down
10 changes: 10 additions & 0 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,16 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
req.callback = callback;

function callback(availInAfter, availOutAfter) {
// When the callback is used in an async write, the callback's
// context is the `req` object that was created. The req object
// is === this._handle, and that's why it's important to null
// out the values after they are done being used. `this._handle`
// can stay in memory longer than the callback and buffer are needed.
if (this) {
this.buffer = null;
this.callback = null;
}

if (self._hadError)
return;

Expand Down
6 changes: 5 additions & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ class ContextifyContext {

Local<Context> ctx = Context::New(env->isolate(), nullptr, object_template);

CHECK(!ctx.IsEmpty());
if (ctx.IsEmpty()) {
env->ThrowError("Could not instantiate context");
return Local<Context>();
}

ctx->SetSecurityToken(env->context()->GetSecurityToken());

// We need to tie the lifetime of the sandbox object with the lifetime of
Expand Down
26 changes: 26 additions & 0 deletions test/parallel/test-vm-low-stack-space.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';
require('../common');
const assert = require('assert');
const vm = require('vm');

function a() {
try {
return a();
} catch (e) {
// Throw an exception as near to the recursion-based RangeError as possible.
return vm.runInThisContext('() => 42')();
}
}

assert.strictEqual(a(), 42);

function b() {
try {
return b();
} catch (e) {
// This writes a lot of noise to stderr, but it still works.
return vm.runInNewContext('() => 42')();
}
}

assert.strictEqual(b(), 42);

0 comments on commit db4b8f2

Please sign in to comment.