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.
pull/22966/head
Ryan Dahl 2009-09-17 14:58:18 +02:00
parent e57c16bc2d
commit b54fad9b3f
1 changed files with 8 additions and 1 deletions

View File

@ -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);