test: do not use uninitialized memory in common flags check
Only use the amount of data that was actually read from the test file. Otherwise, there is a small risk of getting false positives, and generally reading uninitialized memory makes using automated memory error detection tools harder. PR-URL: https://github.com/nodejs/node/pull/25475 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
55e0ad9ae6
commit
27f9a55cf6
@ -57,9 +57,9 @@ if (process.argv.length === 2 &&
|
||||
const bytesToRead = 1500;
|
||||
const buffer = Buffer.allocUnsafe(bytesToRead);
|
||||
const fd = fs.openSync(module.parent.filename, 'r');
|
||||
fs.readSync(fd, buffer, 0, bytesToRead);
|
||||
const bytesRead = fs.readSync(fd, buffer, 0, bytesToRead);
|
||||
fs.closeSync(fd);
|
||||
const source = buffer.toString();
|
||||
const source = buffer.toString('utf8', 0, bytesRead);
|
||||
|
||||
const flagStart = source.indexOf('// Flags: --') + 10;
|
||||
if (flagStart !== 9) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user