Commit c3d9ccd
Reliable clean-up of SafeHandles in Deflater/Inflater (#114826)
Fixes #89445
This reimplements #71991 in `Deflater` and `Inflater`. The PR was
previously reverted in #85001 as a result of issue #84994.
As noted in the reverting PR, `Deflater` simply needed to dispose of the
returned SafeHandle and supress its own finalizer if
`CreateZLibStreamForDeflate` threw an exception. We now do this.
We couldn't do this for `Inflater` at the time - it had to support
concatenated GZip data, and as part of that support it would recreate
its `ZLibStreamHandle`. As a result of #113587, this recreation no
longer happens and we can treat `Inflater` as we would treat `Deflater`.
I've refactored `Inflater.InflateInit` out of existence and made
`_zlibStream` readonly to reflect this.
This also incorporates a change to both class' `DeallocateBufferHandle`
methods (when called by `Dispose`) to prevent them dereferencing a
`ZLibStreamHandle` after it's been disposed of. This is roughly how
#84994 was originally discovered.
---------
Co-authored-by: Radek Zikmund <[email protected]>1 parent eaafd7c commit c3d9ccd
File tree
10 files changed
+169
-165
lines changed- src/libraries
- Common/src/System/IO/Compression
- System.IO.Compression/src
- Resources
- System/IO/Compression/DeflateZLib
- System.Net.WebSockets/src
- Resources
- System/Net/WebSockets/Compression
10 files changed
+169
-165
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 93 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
176 | 212 | | |
177 | 213 | | |
178 | 214 | | |
| |||
228 | 264 | | |
229 | 265 | | |
230 | 266 | | |
231 | | - | |
| 267 | + | |
232 | 268 | | |
233 | | - | |
234 | | - | |
| 269 | + | |
235 | 270 | | |
236 | | - | |
| 271 | + | |
237 | 272 | | |
238 | | - | |
239 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
240 | 278 | | |
241 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
242 | 289 | | |
243 | 290 | | |
244 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
245 | 314 | | |
246 | 315 | | |
247 | 316 | | |
| |||
267 | 336 | | |
268 | 337 | | |
269 | 338 | | |
270 | | - | |
| 339 | + | |
271 | 340 | | |
272 | | - | |
273 | | - | |
| 341 | + | |
274 | 342 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
| 343 | + | |
279 | 344 | | |
280 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
281 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
282 | 359 | | |
283 | 360 | | |
284 | 361 | | |
| |||
317 | 394 | | |
318 | 395 | | |
319 | 396 | | |
320 | | - | |
| 397 | + | |
321 | 398 | | |
322 | 399 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | 400 | | |
337 | 401 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
Lines changed: 23 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
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 | | - | |
| 32 | + | |
62 | 33 | | |
63 | 34 | | |
64 | 35 | | |
| |||
77 | 48 | | |
78 | 49 | | |
79 | 50 | | |
| 51 | + | |
80 | 52 | | |
| 53 | + | |
81 | 54 | | |
82 | | - | |
| 55 | + | |
| 56 | + | |
83 | 57 | | |
84 | 58 | | |
85 | 59 | | |
| |||
129 | 103 | | |
130 | 104 | | |
131 | 105 | | |
132 | | - | |
| 106 | + | |
133 | 107 | | |
134 | 108 | | |
135 | 109 | | |
| |||
179 | 153 | | |
180 | 154 | | |
181 | 155 | | |
182 | | - | |
| 156 | + | |
183 | 157 | | |
184 | 158 | | |
185 | 159 | | |
186 | | - | |
187 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
188 | 166 | | |
189 | 167 | | |
190 | 168 | | |
| |||
217 | 195 | | |
218 | 196 | | |
219 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
220 | 207 | | |
221 | 208 | | |
0 commit comments