toStringz and toUTFz potentially unsafe

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Jul 24 18:15:37 PDT 2011


On 7/24/11 8:05 PM, Brad Roberts wrote:
> Not entire true.  There's one more very important way this can cause a
> serious problem:  when the string in question is at the end of a block
> of memory and the +1 location is outside that.  The result will be a
> segv.

Good point. In fact the implementation already takes care of that.

https://github.com/D-Programming-Language/phobos/blob/master/std/string.d#L403

Andrei


More information about the Digitalmars-d mailing list