diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2017-11-07 21:28:13 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2017-11-09 12:57:16 +0100 |
commit | f823d381e700ec152575ebd2cdc4420def690833 (patch) | |
tree | 83915ceb6c50388ab0aa4fa180e20077f146da22 /test/fixtures | |
parent | e5238ed030a06fa94e4574eff504777e173c9351 (diff) | |
download | android-node-v8-f823d381e700ec152575ebd2cdc4420def690833.tar.gz android-node-v8-f823d381e700ec152575ebd2cdc4420def690833.tar.bz2 android-node-v8-f823d381e700ec152575ebd2cdc4420def690833.zip |
src: fix UB in InternalModuleReadFile()
`&vec[0]` is undefined behavior when `vec.size() == 0`.
It is mostly academic because package.json files are not usually empty
and because with most STL implementations it decays to something that
is legal C++ as long as the result is not dereferenced, but better safe
than sorry.
Note that the tests don't actually fail because of that, I added them
as sanity checks.
PR-URL: https://github.com/nodejs/node/pull/16871
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/fixtures')
-rw-r--r-- | test/fixtures/empty-with-bom.txt | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/test/fixtures/empty-with-bom.txt b/test/fixtures/empty-with-bom.txt new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/fixtures/empty-with-bom.txt @@ -0,0 +1 @@ +
\ No newline at end of file |