Commit 04fa12b
committed
stdlib: Fix unicode_util:gc/1 breaking binary continuations
The gc/1 fast-path for $\r was calling cp(R0) and returning
[CP|T] when \r was not followed by \n. This "exploded" the
binary tail into mixed chardata (integers + binary fragments),
which downstream functions in string.erl (bin_search_loop,
bin_search_inv_n) could not handle — they expect
[BinR|Cont] when is_binary(BinR).
This caused string:trim/3 to return wrong results or crash
with {case_clause,[]} when trimming strings containing binaries
followed by another list element, and the binary contained $\r
not followed by $\n.
Fix: return the original input (Str) instead of [CP|cp(R0)],
consistent with what gc_1/1 already does.
Closes #113801 parent c388a2d commit 04fa12b
3 files changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
126 | 132 | | |
127 | 133 | | |
128 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
669 | | - | |
| 669 | + | |
670 | 670 | | |
671 | 671 | | |
672 | | - | |
| 672 | + | |
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
| |||
0 commit comments