Commit f7724ab
node-api: avoid crashing on passed-in null string
When `napi_create_string_*` receives a null pointer as its second
argument, it must null-check it before passing it into V8, otherwise a
crash will occur.
Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com>
PR-URL: #38923
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>1 parent 8c7b2ba commit f7724abCopy full SHA for f7724ab
File tree
Expand file treeCollapse file tree
6 files changed
+108
-1
lines changedOpen diff view settings
Filter options
- src
- test/js-native-api/test_string
Expand file treeCollapse file tree
6 files changed
+108
-1
lines changedOpen diff view settings
Collapse file
+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1485 | 1485 | |
1486 | 1486 | |
1487 | 1487 | |
| 1488 | + |
| 1489 | + |
1488 | 1490 | |
1489 | 1491 | |
1490 | 1492 | |
| ||
1507 | 1509 | |
1508 | 1510 | |
1509 | 1511 | |
| 1512 | + |
| 1513 | + |
1510 | 1514 | |
1511 | 1515 | |
1512 | 1516 | |
| ||
1528 | 1532 | |
1529 | 1533 | |
1530 | 1534 | |
| 1535 | + |
| 1536 | + |
1531 | 1537 | |
1532 | 1538 | |
1533 | 1539 | |
|
Collapse file
test/js-native-api/test_string/binding.gyp
Copy file name to clipboardExpand all lines: test/js-native-api/test_string/binding.gyp+3-1Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
4 | 4 | |
5 | 5 | |
6 | 6 | |
7 | | - |
| 7 | + |
| 8 | + |
| 9 | + |
8 | 10 | |
9 | 11 | |
10 | 12 | |
|
Collapse file
test/js-native-api/test_string/test_null.c
Copy file name to clipboard+71Lines changed: 71 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
Collapse file
test/js-native-api/test_string/test_null.h
Copy file name to clipboard+8Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
Collapse file
test/js-native-api/test_string/test_null.js
Copy file name to clipboard+17Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
Collapse file
test/js-native-api/test_string/test_string.c
Copy file name to clipboardExpand all lines: test/js-native-api/test_string/test_string.c+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
2 | 2 | |
3 | 3 | |
4 | 4 | |
| 5 | + |
5 | 6 | |
6 | 7 | |
7 | 8 | |
| ||
283 | 284 | |
284 | 285 | |
285 | 286 | |
| 287 | + |
| 288 | + |
286 | 289 | |
287 | 290 | |
288 | 291 | |
|
0 commit comments