Bug 18279 – rt.util.utf does not properly reserve buffer in toUTF16/toUTF16z
Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-22T17:46:24Z
Last change time
2018-01-30T13:27:38Z
Keywords
pull
Assigned to
No Owner
Creator
Nathan S.
Comments
Comment #0 by n8sh.secondary — 2018-01-22T17:46:24Z
The offending pattern:
```
wchar[] r;
size_t slen = s.length;
r.length = slen;
r.length = 0;
// ... followed by code that appends to r with ~=
```
The apparent intention is to preallocate the buffer but this idiom doesn't work as pointed out by Dmitry Olshansky: "On append the slice is not the tail so it will reallocate." https://github.com/dlang/phobos/pull/6024#discussion_r160918451