From aca275f58db0ce3da247b35588ebec563c7ba937 Mon Sep 17 00:00:00 2001 From: Brian White Date: Tue, 7 May 2013 18:01:42 -0400 Subject: [PATCH] stream_wrap: fix memory leak on early return --- src/stream_wrap.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index f1d8af1c83..04b08814ce 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -538,9 +538,6 @@ Handle StreamWrap::Writev(const Arguments& args) { uv_buf_t bufs_[16]; uv_buf_t* bufs = bufs_; - if (ARRAY_SIZE(bufs_) < count) - bufs = new uv_buf_t[count]; - // Determine storage size first size_t storage_size = 0; for (size_t i = 0; i < count; i++) { @@ -578,6 +575,9 @@ Handle StreamWrap::Writev(const Arguments& args) { return scope.Close(v8::Null(node_isolate)); } + if (ARRAY_SIZE(bufs_) < count) + bufs = new uv_buf_t[count]; + storage_size += sizeof(WriteWrap); char* storage = new char[storage_size]; WriteWrap* req_wrap = new (storage) WriteWrap();