Commit c061fbf
committed
fix: heap-use-after-free in build_backtrace when dbuf OOM frees current_exception
If JS_NewError() during build_backtrace triggered dbuf OOM, JS_ThrowOutOfMemory
freed the current exception (error_val from the caller's stack frame), then
the rest of build_backtrace continued using the freed error_val for the
prepareStackTrace call and the JS_DefinePropertyValue of the stack property.
The fix duplicates error_val into a local error_obj at function entry, uses
error_obj throughout the function, and frees it at exit.
Fixes #14691 parent a653771 commit c061fbf
2 files changed
Lines changed: 38 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
765 | 765 | | |
766 | 766 | | |
767 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
768 | 799 | | |
769 | 800 | | |
770 | 801 | | |
| |||
1042 | 1073 | | |
1043 | 1074 | | |
1044 | 1075 | | |
| 1076 | + | |
1045 | 1077 | | |
1046 | 1078 | | |
1047 | 1079 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7743 | 7743 | | |
7744 | 7744 | | |
7745 | 7745 | | |
7746 | | - | |
| 7746 | + | |
7747 | 7747 | | |
7748 | 7748 | | |
7749 | 7749 | | |
| |||
7760 | 7760 | | |
7761 | 7761 | | |
7762 | 7762 | | |
| 7763 | + | |
7763 | 7764 | | |
7764 | 7765 | | |
7765 | 7766 | | |
| |||
7905 | 7906 | | |
7906 | 7907 | | |
7907 | 7908 | | |
7908 | | - | |
| 7909 | + | |
7909 | 7910 | | |
7910 | 7911 | | |
7911 | 7912 | | |
| |||
7926 | 7927 | | |
7927 | 7928 | | |
7928 | 7929 | | |
7929 | | - | |
7930 | | - | |
| 7930 | + | |
| 7931 | + | |
7931 | 7932 | | |
7932 | 7933 | | |
7933 | 7934 | | |
7934 | 7935 | | |
7935 | 7936 | | |
| 7937 | + | |
7936 | 7938 | | |
7937 | 7939 | | |
7938 | 7940 | | |
| |||
0 commit comments