Browse Source

Bugfix: node.fs.write() was stack allocating buffer.

Since the buffer is passed to the thread pool it needs to be heap allocated.
Thanks to Jon Crosby and Tim Caswell for debugging this.
v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
b54fad9b3f
  1. 9
      src/file.cc

9
src/file.cc

@ -138,9 +138,15 @@ EIOPromise::After (eio_req *req)
break;
case EIO_OPEN:
argc = 1;
argv[0] = Integer::New(req->result);
break;
case EIO_WRITE:
argc = 1;
argv[0] = Integer::New(req->result);
assert(req->ptr2);
delete req->ptr2;
break;
case EIO_STAT:
@ -336,7 +342,8 @@ Write (const Arguments& args)
Local<Value> exception = Exception::TypeError(String::New("Bad argument"));
return ThrowException(exception);
}
char buf[len];
char * buf = new char[len];
ssize_t written = DecodeWrite(buf, len, args[1], enc);
assert(written == len);

Loading…
Cancel
Save