Commit 81970f8
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: #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>1 parent 4ede5ec commit 81970f8Copy full SHA for 81970f8
File tree
Expand file treeCollapse file tree
3 files changed
+21
-6
lines changedOpen diff view settings
Filter options
- src
- test
- fixtures
- parallel
Expand file treeCollapse file tree
3 files changed
+21
-6
lines changedOpen diff view settings
Collapse file
+11-6Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
539 | 539 | |
540 | 540 | |
541 | 541 | |
542 | | - |
543 | | - |
544 | | - |
545 | | - |
546 | | - |
547 | | - |
| 542 | + |
| 543 | + |
| 544 | + |
| 545 | + |
| 546 | + |
| 547 | + |
| 548 | + |
| 549 | + |
| 550 | + |
| 551 | + |
| 552 | + |
548 | 553 | |
549 | 554 | |
550 | 555 | |
|
Collapse file
test/fixtures/empty-with-bom.txt
Copy file name to clipboard+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
Collapse file
test/parallel/test-module-binding.js
Copy file name to clipboard+9Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
0 commit comments