summaryrefslogtreecommitdiff
path: root/src/node_i18n.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-11-29 05:22:40 -0600
committerAnna Henningsen <anna@addaleax.net>2016-12-06 01:42:08 +0100
commit69b1a76ddd54d42b1c51fffe292d083c6dc165df (patch)
treed5da1489afe533ec90a2fa5eef1ebb675ad10b0f /src/node_i18n.cc
parent18cf668d405b0d226408e8397b76881b23e7d93e (diff)
downloadandroid-node-v8-69b1a76ddd54d42b1c51fffe292d083c6dc165df.tar.gz
android-node-v8-69b1a76ddd54d42b1c51fffe292d083c6dc165df.tar.bz2
android-node-v8-69b1a76ddd54d42b1c51fffe292d083c6dc165df.zip
buffer: fix transcode for single-byte enc to ucs2
Fix `buffer.transcode()` for transcoding from single-byte character encodings to UCS2. These would previously perform out-of-bounds reads due to an incorrect `sizeof()` expression. Fixes: https://github.com/nodejs/node/issues/9834 PR-URL: https://github.com/nodejs/node/pull/9838 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_i18n.cc')
-rw-r--r--src/node_i18n.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/node_i18n.cc b/src/node_i18n.cc
index bab06cfcdf..a98fdca4d1 100644
--- a/src/node_i18n.cc
+++ b/src/node_i18n.cc
@@ -179,7 +179,7 @@ MaybeLocal<Object> TranscodeToUcs2(Isolate* isolate,
MaybeLocal<Object> ret;
MaybeStackBuffer<UChar> destbuf(source_length);
Converter from(fromEncoding);
- const size_t length_in_chars = source_length * sizeof(*destbuf);
+ const size_t length_in_chars = source_length * sizeof(UChar);
ucnv_toUChars(from.conv, *destbuf, length_in_chars,
source, source_length, status);
if (U_SUCCESS(*status))