Commit 48c4afb
authored
Rollup merge of rust-lang#78499 - SkiFire13:fix-string-retain, r=m-ou-se
Prevent String::retain from creating non-utf8 strings when abusing panic
Fixes rust-lang#78498
The idea is the same as `Vec::drain`, set the len to 0 so that nobody can observe the broken invariant if it escapes the function (in this case if `f` panics)2 files changed
+21
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1235 | 1235 | | |
1236 | 1236 | | |
1237 | 1237 | | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
1238 | 1242 | | |
1239 | 1243 | | |
1240 | 1244 | | |
| |||
1255 | 1259 | | |
1256 | 1260 | | |
1257 | 1261 | | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
| 1262 | + | |
| 1263 | + | |
1262 | 1264 | | |
1263 | 1265 | | |
1264 | 1266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
378 | 379 | | |
379 | 380 | | |
380 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
381 | 396 | | |
382 | 397 | | |
383 | 398 | | |
| |||
0 commit comments