mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 08:30:33 +03:00
fix Issue 18800 - Array.length setter segfaults for payloads with indirections
This commit is contained in:
parent
16f812ac01
commit
b2016be155
1 changed files with 10 additions and 2 deletions
|
@ -324,7 +324,7 @@ if (!is(Unqual!T == bool))
|
||||||
auto newPayloadPtr = cast(T*) malloc(nbytes);
|
auto newPayloadPtr = cast(T*) malloc(nbytes);
|
||||||
newPayloadPtr || assert(false, "std.container.Array.length failed to allocate memory.");
|
newPayloadPtr || assert(false, "std.container.Array.length failed to allocate memory.");
|
||||||
auto newPayload = newPayloadPtr[0 .. newLength];
|
auto newPayload = newPayloadPtr[0 .. newLength];
|
||||||
memcpy(newPayload.ptr, _payload.ptr, _payload.sizeof);
|
memcpy(newPayload.ptr, _payload.ptr, startEmplace * T.sizeof);
|
||||||
memset(newPayload.ptr + startEmplace, 0,
|
memset(newPayload.ptr + startEmplace, 0,
|
||||||
(newLength - startEmplace) * T.sizeof);
|
(newLength - startEmplace) * T.sizeof);
|
||||||
GC.addRange(newPayload.ptr, nbytes);
|
GC.addRange(newPayload.ptr, nbytes);
|
||||||
|
@ -1136,11 +1136,19 @@ if (!is(Unqual!T == bool))
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
// REG https://issues.dlang.org/show_bug.cgi?id=13621
|
// https://issues.dlang.org/show_bug.cgi?id=13621
|
||||||
import std.container : Array, BinaryHeap;
|
import std.container : Array, BinaryHeap;
|
||||||
alias Heap = BinaryHeap!(Array!int);
|
alias Heap = BinaryHeap!(Array!int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@system unittest
|
||||||
|
{
|
||||||
|
// https://issues.dlang.org/show_bug.cgi?id=18800
|
||||||
|
static struct S { void* p; }
|
||||||
|
Array!S a;
|
||||||
|
a.length = 10;
|
||||||
|
}
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
Array!int a;
|
Array!int a;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue