Commit 794b7e1
committed
Fix crash and leak in DiffHunk.lines and Patch.hunks
On allocation failure PyList_New() returns NULL, and the previous code
dereferenced it while setting items. Also, the partially built list was
leaked on every mid-loop early return.
Fixes #1479
Assisted-by: Kimi Code1 parent e6204dc commit 794b7e1
3 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
835 | 838 | | |
836 | 839 | | |
837 | | - | |
| 840 | + | |
| 841 | + | |
838 | 842 | | |
| 843 | + | |
839 | 844 | | |
840 | 845 | | |
841 | | - | |
| 846 | + | |
| 847 | + | |
842 | 848 | | |
| 849 | + | |
843 | 850 | | |
844 | 851 | | |
845 | 852 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
226 | 229 | | |
227 | 230 | | |
228 | | - | |
| 231 | + | |
| 232 | + | |
229 | 233 | | |
| 234 | + | |
230 | 235 | | |
231 | 236 | | |
232 | 237 | | |
| |||
0 commit comments