mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 09:08:46 +00:00

`&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>
10 lines
395 B
JavaScript
10 lines
395 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const { internalModuleReadFile } = process.binding('fs');
|
|
const { strictEqual } = require('assert');
|
|
|
|
strictEqual(internalModuleReadFile('nosuchfile'), undefined);
|
|
strictEqual(internalModuleReadFile(fixtures.path('empty.txt')), '');
|
|
strictEqual(internalModuleReadFile(fixtures.path('empty-with-bom.txt')), '');
|