summaryrefslogtreecommitdiff
path: root/lib/buffer.js
diff options
context:
space:
mode:
authorNikolai Vavilov <vvnicholas@gmail.com>2017-02-05 14:14:53 +0200
committerGitHub <noreply@github.com>2017-02-05 14:14:53 +0200
commit9a0829d7281666eafeb6b0136fad0356f031eb4a (patch)
tree9f248f8296939f546d51ff1ce85ad8d8f57287dc /lib/buffer.js
parent67af1ad671d8d8a1dd6358339436f8b9718fc3d9 (diff)
downloadandroid-node-v8-9a0829d7281666eafeb6b0136fad0356f031eb4a.tar.gz
android-node-v8-9a0829d7281666eafeb6b0136fad0356f031eb4a.tar.bz2
android-node-v8-9a0829d7281666eafeb6b0136fad0356f031eb4a.zip
buffer: stricter argument checking in toString
This prevents the confusing behavior of `buf.toString(0, 5)` by disallowing passing `0` as the encoding. PR-URL: https://github.com/nodejs/node/pull/11120 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'lib/buffer.js')
-rw-r--r--lib/buffer.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index 0a8724bda4..cb93d7e248 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -463,7 +463,7 @@ function slowToString(encoding, start, end) {
if (end <= start)
return '';
- if (!encoding) encoding = 'utf8';
+ if (encoding === undefined) encoding = 'utf8';
while (true) {
switch (encoding) {