summaryrefslogtreecommitdiff
path: root/src/udp_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-08-07 23:03:00 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2015-08-13 20:03:41 +0200
commit64577463dfbc7ebe646c6c5a06e4b309b2757205 (patch)
tree545d278d9489706ba1689d08cf01b0d712c79e77 /src/udp_wrap.cc
parent27813339cf713275fa7bbf2ae497d13b66aa78ce (diff)
downloadandroid-node-v8-64577463dfbc7ebe646c6c5a06e4b309b2757205.tar.gz
android-node-v8-64577463dfbc7ebe646c6c5a06e4b309b2757205.tar.bz2
android-node-v8-64577463dfbc7ebe646c6c5a06e4b309b2757205.zip
src: plug memory leaks
In a few places dynamic memory was passed to the Buffer::New() overload that makes a copy of the input, not the one that takes ownership. This commit is a band-aid to fix the memory leaks. Longer term, we should look into using C++11 move semantics more effectively. Fixes: https://github.com/nodejs/node/issues/2308 PR-URL: https://github.com/nodejs/node/pull/2352 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/udp_wrap.cc')
-rw-r--r--src/udp_wrap.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc
index dd3958ec0e..791ef76848 100644
--- a/src/udp_wrap.cc
+++ b/src/udp_wrap.cc
@@ -408,7 +408,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
}
char* base = static_cast<char*>(realloc(buf->base, nread));
- argv[2] = Buffer::New(env, base, nread).ToLocalChecked();
+ argv[2] = Buffer::Use(env, base, nread).ToLocalChecked();
argv[3] = AddressToJS(env, addr);
wrap->MakeCallback(env->onmessage_string(), ARRAY_SIZE(argv), argv);
}