From e6a30bd1077ee6dc4139f423db052c3de50ad1ef Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 9 Jan 2012 15:29:15 -0800 Subject: [PATCH] Fix #2473 Tested in production. See also http://code.google.com/p/v8/issues/detail?id=1889 --- src/node_buffer.h | 3 +-- src/stream_wrap.cc | 14 +++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/node_buffer.h b/src/node_buffer.h index ea3311245c6..ef7cf4fd837 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -65,6 +65,7 @@ namespace node { class NODE_EXTERN Buffer: public ObjectWrap { public: + static v8::Persistent constructor_template; static bool HasInstance(v8::Handle val); @@ -99,8 +100,6 @@ class NODE_EXTERN Buffer: public ObjectWrap { free_callback callback, void *hint); // public constructor private: - static v8::Persistent constructor_template; - static v8::Handle New(const v8::Arguments &args); static v8::Handle BinarySlice(const v8::Arguments &args); static v8::Handle AsciiSlice(const v8::Arguments &args); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 95a19c7ea6e..b3630497933 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -149,13 +149,17 @@ Handle StreamWrap::ReadStop(const Arguments& args) { } -inline char* StreamWrap::NewSlab(Handle global, - Handle wrap_obj) { - Buffer* b = Buffer::New(SLAB_SIZE); - global->SetHiddenValue(slab_sym, b->handle_); +char* StreamWrap::NewSlab(Handle global, + Handle wrap_obj) { + HandleScope scope; + Local arg = Integer::NewFromUnsigned(SLAB_SIZE); + Local b = Buffer::constructor_template->GetFunction()-> + NewInstance(1, &arg); + if (b.IsEmpty()) return NULL; + global->SetHiddenValue(slab_sym, b); assert(Buffer::Length(b) == SLAB_SIZE); slab_used = 0; - wrap_obj->SetHiddenValue(slab_sym, b->handle_); + wrap_obj->SetHiddenValue(slab_sym, b); return Buffer::Data(b); }