Commit 4b45e07
committed
gh-144984: Fix crash in ExternalEntityParserCreate() error paths
When ExternalEntityParserCreate() hits an error path (allocation
failure), Py_DECREF(new_parser) triggers xmlparse_dealloc() on a
partially-initialized object:
1. handlers is NULL, so clear_handlers dereferences NULL (SEGV).
2. Py_CLEAR(parent) in dealloc already decrements the parent's
refcount, so the explicit Py_DECREF(self) is a double-decrement.
Fix by adding a NULL guard in clear_handlers and setting parent to
NULL before Py_DECREF(new_parser) in each error path so that dealloc
does not over-decrement the parent's refcount.1 parent e84a2cc commit 4b45e07
File tree
3 files changed
+38
-0
lines changed- Lib/test
- Misc/NEWS.d/next/Library
- Modules
3 files changed
+38
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
827 | 856 | | |
828 | 857 | | |
829 | 858 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1097 | 1097 | | |
1098 | 1098 | | |
1099 | 1099 | | |
| 1100 | + | |
1100 | 1101 | | |
1101 | 1102 | | |
1102 | 1103 | | |
1103 | 1104 | | |
1104 | 1105 | | |
1105 | 1106 | | |
| 1107 | + | |
1106 | 1108 | | |
1107 | 1109 | | |
1108 | 1110 | | |
| |||
1117 | 1119 | | |
1118 | 1120 | | |
1119 | 1121 | | |
| 1122 | + | |
1120 | 1123 | | |
1121 | 1124 | | |
1122 | 1125 | | |
| |||
2489 | 2492 | | |
2490 | 2493 | | |
2491 | 2494 | | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
2492 | 2498 | | |
2493 | 2499 | | |
2494 | 2500 | | |
| |||
0 commit comments