0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00

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.
This commit is contained in:
Ryan Dahl 2009-09-17 14:58:18 +02:00
parent e57c16bc2d
commit b54fad9b3f

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