Browse Source

Fix #2473

Tested in production.

See also http://code.google.com/p/v8/issues/detail?id=1889
v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
e6a30bd107
  1. 3
      src/node_buffer.h
  2. 14
      src/stream_wrap.cc

3
src/node_buffer.h

@ -65,6 +65,7 @@ namespace node {
class NODE_EXTERN Buffer: public ObjectWrap {
public:
static v8::Persistent<v8::FunctionTemplate> constructor_template;
static bool HasInstance(v8::Handle<v8::Value> val);
@ -99,8 +100,6 @@ class NODE_EXTERN Buffer: public ObjectWrap {
free_callback callback, void *hint); // public constructor
private:
static v8::Persistent<v8::FunctionTemplate> constructor_template;
static v8::Handle<v8::Value> New(const v8::Arguments &args);
static v8::Handle<v8::Value> BinarySlice(const v8::Arguments &args);
static v8::Handle<v8::Value> AsciiSlice(const v8::Arguments &args);

14
src/stream_wrap.cc

@ -149,13 +149,17 @@ Handle<Value> StreamWrap::ReadStop(const Arguments& args) {
}
inline char* StreamWrap::NewSlab(Handle<Object> global,
Handle<Object> wrap_obj) {
Buffer* b = Buffer::New(SLAB_SIZE);
global->SetHiddenValue(slab_sym, b->handle_);
char* StreamWrap::NewSlab(Handle<Object> global,
Handle<Object> wrap_obj) {
HandleScope scope;
Local<Value> arg = Integer::NewFromUnsigned(SLAB_SIZE);
Local<Object> 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);
}

Loading…
Cancel
Save