Commit c2e2878
Move parser.finalize() inside try/except in MultiPartParser.parse() (#3153)
parser.finalize() can trigger callbacks that raise MultiPartException
(e.g. when multipart data is truncated or malformed). Since it was
called outside the try/except block, any exception raised during
finalize would skip the file cleanup, leaking SpooledTemporaryFile
handles until the garbage collector eventually collects them.
Moving finalize() inside the try block ensures that temporary files
are properly closed on any MultiPartException, whether it occurs
during chunk processing or during finalization.
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>1 parent 89630a8 commit c2e2878
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
275 | | - | |
276 | 276 | | |
0 commit comments