mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Fix issue with appending zero items to an array that was previously
handled by allocating an empty array with metadata!
This commit is contained in:
parent
d370a117b4
commit
76fb1c03f2
1 changed files with 5 additions and 2 deletions
|
@ -1115,6 +1115,11 @@ byte[] _d_arrayappendcTX(const TypeInfo ti, return scope ref byte[] px, size_t n
|
|||
import core.exception : onOutOfMemoryError;
|
||||
// This is a cut&paste job from _d_arrayappendT(). Should be refactored.
|
||||
|
||||
// Short circuit if no data is being appended.
|
||||
if (n == 0)
|
||||
return px;
|
||||
|
||||
|
||||
// only optimize array append where ti is not a shared type
|
||||
auto tinext = unqualify(ti.next);
|
||||
auto sizeelem = tinext.tsize; // array element size
|
||||
|
@ -1132,8 +1137,6 @@ byte[] _d_arrayappendcTX(const TypeInfo ti, return scope ref byte[] px, size_t n
|
|||
auto ptr = cast(byte*) GC.malloc(newcap, attrs, tinext);
|
||||
if (ptr is null)
|
||||
{
|
||||
import core.stdc.stdio;
|
||||
printf("here, ptr=%p, size=%lld, newcap=%lld, newsize=%lld, newlength=%lld, length=%lld, attrs=%02x\n", px.ptr, size, newcap, newsize, newlength, length, attrs);
|
||||
onOutOfMemoryError();
|
||||
assert(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue