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
Comment #1 by schveiguy — 2018-01-28T17:40:14Z
Comment #2 by schveiguy — 2018-01-28T21:02:48Z
(In reply to Steven Schveighoffer from comment #1) > PR: https://github.com/dlang/druntime/pull/2065 Already open PR: https://github.com/dlang/druntime/pull/2053
Comment #3 by github-bugzilla — 2018-01-30T13:27:37Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/a7739219026e9b175949a322f9d88c4abb71b346 Fix Issue 18279 - rt.util.utf does not properly reserve buffer in toUTF16/toUTF16z https://github.com/dlang/druntime/commit/50633486594c32d5d7fbdbc8fcf98a7aff15e920 Merge pull request #2053 from n8sh/utf-reserve Fix Issue 18279 - rt.util.utf does not properly reserve buffer in toUTF16/toUTF16z merged-on-behalf-of: Steven Schveighoffer <[email protected]>