summaryrefslogtreecommitdiff
path: root/src/string_bytes.cc
AgeCommit message (Collapse)Author
2019-08-09src: add error codes to errors thrown in C++Yaniv Friedensohn
PR-URL: https://github.com/nodejs/node/pull/27700 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-03-07buffer: do not affect memory after target for utf16 writeAnna Henningsen
Do not write one character too much before shifting the whole result to the left when using UTF16-LE, possibly overwriting already-used memory while doing so. Fixes: https://github.com/nodejs/node/issues/26422 PR-URL: https://github.com/nodejs/node/pull/26432 Fixes: https://github.com/nodejs/node/issues/26422 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-27src: apply clang-tidy rule modernize-deprecated-headersgengjiawen
PR-URL: https://github.com/nodejs/node/pull/26159 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-21src: reduce includes of node_internals.hJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/25507 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-09-03src: allow UTF-16 in generic StringBytes decode callAnna Henningsen
This allows removing a number of special cases in other parts of the code, at least one of which was incorrect in expecting aligned input when that was not guaranteed. Fixes: https://github.com/nodejs/node/issues/22358 PR-URL: https://github.com/nodejs/node/pull/22622 Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-09-02src: rework (mostly internal) functions to use MaybesUjjwal Sharma
Rework all affected functions to use Maybes, thus improving error handling substantially in internal functions, API functions as well as utilities. Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: https://github.com/nodejs/node/pull/21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-09-02src: remove calls to deprecated v8 functions (ToString)Ujjwal Sharma
Remove all calls to deprecated v8 functions (here: Value::ToString) inside the code (src directory only). PR-URL: https://github.com/nodejs/node/pull/21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-08-29src: use String::Utf8Length with isolateMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/22531 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-29src: use String::Write{OneByte,Utf8} with isolateMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/22531 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-16buffer: avoid overrun on UCS-2 string writeRod Vagg
CVE-2018-12115 Discovered by ChALkeR - Сковорода Никита Андреевич Fix by Anna Henningsen Writing to the second-to-last byte with UCS-2 encoding will cause a -1 length to be send to String::Write(), writing all of the provided Buffer from that point and beyond. Fixes: https://github.com/nodejs-private/security/issues/203 PR-URL: https://github.com/nodejs-private/node-private/pull/138
2018-07-14src,tools: use https://nodejs.org URL when possible.XhmikosR
PR-URL: https://github.com/nodejs/node/pull/21719 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-04-10src: rename ERR_STRING_TOO_LARGE to ERR_STRING_TOO_LONGJoyee Cheung
The old error name and message were trying to be consistent with ERR_BUFFER_TOO_LARGE but they were not really accurate. The kStringMaxLength was measured in number of characters, not number of bytes. The name ERR_STRING_TOO_LARGE also seems a bit awkward. This patch tries to correct them before they get released to users. PR-URL: https://github.com/nodejs/node/pull/19864 Refs: https://github.com/nodejs/node/pull/19739 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-04-07src: migrate string_bytes.cc to throw errors with codeJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/19739 Fixes: https://github.com/nodejs/node/issues/3175 Fixes: https://github.com/nodejs/node/issues/9489 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-04-07buffer: reduce overhead of StringBytes::Encode for UCS2Joyee Cheung
Currently calling StringBytes::Encode on a UCS2 buffer results in two copies of the buffer and the usage of std::vector::assign makes the memory usage unpredictable, and therefore hard to test against. This patch makes the memory usage more predictable by allocating the memory using node::UncheckedMalloc and handles the memory allocation failure properly. Only one copy of the buffer will be created and it will be freed upon GC of the string. PR-URL: https://github.com/nodejs/node/pull/19798 Refs: https://github.com/nodejs/node/pull/19739 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-23src: fix upcoming V8 deprecation warningsSarat Addepalli
PR-URL: https://github.com/nodejs/node/pull/19490 Fixes: https://github.com/nodejs/node/issues/18909 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2018-01-23src: fix fs.write() externalized string handlingBen Noordhuis
* Respect `encoding` argument when the string is externalized. * Copy the string when the write request can outlive the externalized string. This commit removes `StringBytes::GetExternalParts()` because it is fundamentally broken. Fixes: https://github.com/nodejs/node/issues/18146 PR-URL: https://github.com/nodejs/node/pull/18216 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2017-09-22src: do not include internals from node_buffer.hAnna Henningsen
`node_buffer.h` is a public header, so it should not be using the `node_internals.h` internal header. Ref: 290315ace7eed6eeeb300754dd68fc1af4d80c9b Fixes: https://github.com/nodejs/node/issues/15552 PR-URL: https://github.com/nodejs/node/pull/15554 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-08-24src: use proper errors as coming from StringBytesAnna Henningsen
The previous errors were incorrect here, as the code only failed in situations where strings exceeded size limits or an OOM situation was encountered, not for invalid encodings (which aren’t even detected explicitly). Unfortunately, these situations are hard to test for. PR-URL: https://github.com/nodejs/node/pull/14579 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-07-27src: replace ASSERT with CHECKBen Noordhuis
Builds always have asserts enabled so there is no point distinguishing between debug-only checks and run-time checks. Replace calls to ASSERT and friends with their CHECK counterparts. Fixes: https://github.com/nodejs/node/issues/14461 PR-URL: https://github.com/nodejs/node/pull/14474 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com> Reviewed-By: XadillaX <admin@xcoder.in>
2017-05-22src: remove unused parametersBrian White
PR-URL: https://github.com/nodejs/node/pull/13085 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2017-05-03src: do proper StringBytes error handlingAnna Henningsen
- Return `MaybeLocal`s from `StringBytes::Encode` - Add an `error` out parameter to pass JS exceptions to the callers (instead of directly throwing) - Simplify some of the string generation methods in `string_bytes.cc` by unifying the `EXTERN_APEX` logic - Reduce usage of deprecated V8 APIs. - Remove error handling logic from JS, the `buffer.*Slice()` methods now throw errors themselves. - Left TODO comments for future semver-major error message improvements. This paves the way for better error messages coming out of the StringBytes methods. Ref: https://github.com/nodejs/node/issues/3175 PR-URL: https://github.com/nodejs/node/pull/12765 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-04-14src: reduce number of exported symbolsAnna Henningsen
Use `static` definitions and anonymous namespaces to reduce the number of symbols that are exported from the `node` binary. PR-URL: https://github.com/nodejs/node/pull/12366 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-03-10meta: restore original copyright headerJames M Snell
A prior io.js era commit inappropriately removed the original copyright statements from the source. This restores those in any files still remaining from that edit. Ref: https://github.com/nodejs/TSC/issues/174 Ref: https://github.com/nodejs/node/pull/10599 PR-URL: https://github.com/nodejs/node/pull/10155 Note: This PR was required, reviewed-by and approved by the Node.js Foundation Legal Committee and the TSC. There is no `Approved-By:` meta data.
2016-10-04src: fix build for older clangZach Bjornson
Removes use of builtins that are unavailable for older clang. Per benchmarks, only uses builtins on Windows, where speedup is significant. Also adds test for unaligned ucs2 buffer write. Between #3410 and #7645, bytes were swapped twice on bigendian platforms if buffer was not two-byte aligned. See comment in #7645. PR-URL: https://github.com/nodejs/node/pull/7645 Fixes: https://github.com/nodejs/node/issues/7618 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-09-29src: provide allocation + nullptr check shortcutsAnna Henningsen
Provide shortcut `node::CheckedMalloc()` and friends that replace `node::Malloc()` + `CHECK_NE(·, nullptr);` combinations in a few places. PR-URL: https://github.com/nodejs/node/pull/8482 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
2016-09-29src: pass desired return type to allocatorsAnna Henningsen
Pass the desired return type directly to the allocation functions, so that the resulting `static_cast` from `void*` becomes unneccessary and the return type can be use as a reasonable default value for the `size` parameter. PR-URL: https://github.com/nodejs/node/pull/8482 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
2016-09-29src: add Malloc() size param + overflow detectionAnna Henningsen
Adds an optional second parameter to `node::Malloc()` and an optional third parameter to `node::Realloc()` giving the size/number of items to be allocated, in the style of `calloc(3)`. Use a proper overflow check using division; the previous `CHECK_GE(n * size, n);` would not detect all cases of overflow (e.g. `size == SIZE_MAX / 2 && n == 3`). PR-URL: https://github.com/nodejs/node/pull/8482 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
2016-09-06src: normalize malloc, reallocMichael Dawson
malloc(0) and realloc(ptr, 0) have implementation-defined behavior in that the standard allows them to either return a unique pointer or a nullptr for zero-sized allocation requests. Normalize by always using a nullptr. - Introduce node::malloc, node::realloc and node::calloc that should be used throught our source. - Update all existing node source files to use the new functions instead of the native allocation functions. Fixes: https://github.com/nodejs/node/issues/7549 PR-URL: https://github.com/nodejs/node/pull/7564 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-07-17buffer: optimize hex_decodeChristopher Jeffrey
PR-URL: https://github.com/nodejs/node/pull/7602 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-06-28src: fix whitespace/indent cpplint warningsBen Noordhuis
PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-06-19src: alias BINARY to LATIN1Ben Noordhuis
Make BINARY an alias for LATIN1 rather than a distinct enum value. PR-URL: https://github.com/nodejs/node/pull/7284 Refs: https://github.com/nodejs/node/pull/7262 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-06-07buffer: introduce latin1 encoding termTrevor Norris
When node began using the OneByte API (f150d56) it also switched to officially supporting ISO-8859-1. Though at the time no new encoding string was introduced. Introduce the new encoding string 'latin1' to be more explicit. The previous 'binary' and documented as an alias to 'latin1'. While many tests have switched to use 'latin1', there are still plenty that do both 'binary' and 'latin1' checks side-by-side to ensure there is no regression. PR-URL: https://github.com/nodejs/node/pull/7111 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-05-23string_bytes: Make base64 encode/decode reusableEugene Ostroukhov
Node already has support for base64 encoding and decoding that is not visible outside the string_bytes.cc file. Our work on providing a support for the Chrome inspector protocol (https://github.com/nodejs/node/pull/6792) requires base64 encoding support. Rather then introducing a second copy of the base64 encoder, we suggest moving this code into a separate header. PR-URL: https://github.com/nodejs/node/pull/6910 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
2016-04-25src: fix check-imports.py linter errorsSakthipriyan Vairamani
This patch fixes all the linter errors. PR-URL: https://github.com/nodejs/node/pull/6105 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-25fs: Buffer and encoding enhancements to fs APIJames M Snell
This makes several changes: 1. Allow path/filename to be passed in as a Buffer on fs methods 2. Add `options.encoding` to fs.readdir, fs.readdirSync, fs.readlink, fs.readlinkSync and fs.watch. 3. Documentation updates For 1... it's now possible to do: ```js fs.open(Buffer('/fs/foo/bar'), 'w+', (err, fd) => { }); ``` For 2... ```js fs.readdir('/fs/foo/bar', {encoding:'hex'}, (err,list) => { }); fs.readdir('/fs/foo/bar', {encoding:'buffer'}, (err, list) => { }); ``` encoding can also be passed as a string ```js fs.readdir('/fs/foo/bar', 'hex', (err,list) => { }); ``` The default encoding is set to UTF8 so this addresses the discrepency that existed previously between fs.readdir and fs.watch handling filenames differently. Fixes: https://github.com/nodejs/node/issues/2088 Refs: https://github.com/nodejs/node/issues/3519 PR-URL: https://github.com/nodejs/node/pull/5616 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-03-03src: update uses of deprecated NewExternalAli Ijaz Sheikh
V8 String::NewExternal is deprecated in 4.9. Migrate string_bytes.cc to the alternatives. PR-URL: https://github.com/nodejs/node/pull/5462 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2016-03-02crypto, string_bytes: treat `buffer` str as `utf8`Fedor Indutny
Do not treat crypto inputs as `binary` strings, convert them to Buffers using `new Buffer(..., 'utf8')`, or using newly updated StringBytes APIs. PR-URL: https://github.com/nodejs/node/pull/5522 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-24src: add BE support to StringBytes::Encode()Bryon Leung
Versions of Node.js after v0.12 have relocated byte-swapping away from the StringBytes::Encode function, thereby causing a nan test (which accesses this function directly) to fail on big-endian machines. This change re-introduces byte swapping in StringBytes::Encode, done via a call to a function in util-inl. Another change in NodeBuffer::StringSlice was necessary to avoid double byte swapping in big-endian function calls to StringSlice. PR-URL: https://github.com/nodejs/node/pull/3410 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-09-06src: replace usage of v8::Handle with v8::LocalMichaël Zasso
v8::Handle is deprecated: https://codereview.chromium.org/1224623004 PR-URL: https://github.com/nodejs/io.js/pull/2202 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-06src: fix memory leak in ExternStringKarl Skomski
v8 will silently return an empty handle which doesn't delete our data if string length is above String::kMaxLength Fixes: https://github.com/nodejs/node/issues/1374 PR-URL: https://github.com/nodejs/node/pull/2402 Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Amended by @rvagg to change author date from "1970-08-16 16:09:02 +0200" to "2015-08-16 16:09:02 +0200" as per discussion @ https://github.com/nodejs/node/issues/2713
2015-08-21string_bytes: fix unaligned write in UCS2Fedor Indutny
Support unaligned output buffer when writing out UCS2 in `StringBytes::Write`. Fix: https://github.com/nodejs/node/issues/2457 PR-URL: https://github.com/nodejs/node/pull/2480 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-04buffer: make additional changes to native APITrevor Norris
Address comments and deprecations left in source files. These changes include: * Remove the deprecated API. * Change Buffer::New() that did a copy of the data to Buffer::Copy() * Change Buffer::Use() to Buffer::New() PR-URL: https://github.com/nodejs/io.js/pull/1825 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04buffer: switch API to return MaybeLocal<T>Trevor Norris
Instead of aborting in case of internal failure, return an empty Local<Object>. Using the MaybeLocal<T> API, users must check their return values. PR-URL: https://github.com/nodejs/io.js/pull/1825 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-07-25src: make base64 decoding 50% fasterBen Noordhuis
Make the inner loop execute fewer compare-and-branch executions per processed byte, resulting in a 50% or more speedup. This coincidentally fixes an out-of-bounds read: while (unbase64(*src) < 0 && src < srcEnd) Should have read: while (src < srcEnd && unbase64(*src) < 0) But this commit removes the offending code altogether. Fixes: https://github.com/nodejs/io.js/issues/2166 PR-URL: https://github.com/nodejs/io.js/pull/2193 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-05-05src: fix deprecated use of Buffer::New()Ben Noordhuis
Pass the isolate explicitly. Overlooked in commit ccb199a ("src: fix deprecation warnings") because g++ 4.8 and 4.9 don't warn for it whereas g++ 5.1 does. PR-URL: https://github.com/iojs/io.js/pull/1577 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-05src: fix ucs-2 buffer encoding regressionBen Noordhuis
StringBytes::Write() did a plain memcpy() when is_extern is true but that's wrong when the source is a two-byte string and the destination a one-byte or UTF-8 string. The impact is limited to strings > 1,031,913 bytes because those are normally the only strings that are externalized, although the use of the 'externalize strings' extension (--expose_externalize_string) can also trigger it. This commit also cleans up the bytes versus characters confusion in StringBytes::Write() because that was closely intertwined with the UCS-2 encoding regression. One wasn't fixable without the other. Fixes: https://github.com/iojs/io.js/issues/1024 Fixes: https://github.com/joyent/node/issues/8683 PR-URL: https://github.com/iojs/io.js/pull/1042 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-05src: fix external string length calculationBen Noordhuis
Make StringBytes::GetExternalParts() return the byte length for two-byte strings, not the character length. Its callers operate on bytes, not characters. This also fixes StringBytes::Size() reporting only half of the actual number of bytes for external two-byte strings. PR-URL: https://github.com/iojs/io.js/pull/1042 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-05src: remove NODE_INVALID_UTF8 environment variableBen Noordhuis
Introduced in joyent/node v0.10 as a backwards compatibility measure. It's an ugly hack and allowing invalid UTF-8 is not a good idea in the first place, remove it. PR-URL: https://github.com/iojs/io.js/pull/1042 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-05src: fix gc heuristic for external twobyte stringsBen Noordhuis
Large external two-byte strings reported their character length instead of their byte length, throwing off the garbage collector heuristic by a factor of two. PR-URL: https://github.com/iojs/io.js/pull/1042 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-05src: remove unused codeBen Noordhuis
PR-URL: https://github.com/iojs/io.js/pull/1042 Reviewed-By: Trevor Norris <trev.norris@gmail.com>