Skip to content

Commit cc6fe5e

Browse files
authored
Merge pull request #158 from dayllenger/fix-segfault
Fix a segfault merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2 parents 4bf38f1 + 98b43c3 commit cc6fe5e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/containers/dynamicarray.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ struct DynamicArray(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange
125125
else if (l >= arr.length)
126126
{
127127
immutable size_t c = arr.length > 512 ? arr.length + 1024 : arr.length << 1;
128+
static if (useGC)
129+
void* oldPtr = arr.ptr;
128130
void[] a = cast(void[]) arr;
129131
allocator.reallocate(a, c * T.sizeof);
130132
arr = cast(typeof(arr)) a;
131133
static if (useGC)
132134
{
133135
import core.memory: GC;
134-
GC.removeRange(arr.ptr);
136+
GC.removeRange(oldPtr);
135137
GC.addRange(arr.ptr, arr.length * T.sizeof);
136138
}
137139
}

0 commit comments

Comments
 (0)