Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion std/algorithm/sorting.d
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,11 @@ schwartzSort(alias transform, alias less = "a < b",
static trustedMalloc(size_t len) @trusted
{
import core.stdc.stdlib : malloc;
return (cast(T*) malloc(len * T.sizeof))[0 .. len];
import core.checkedint : mulu;
bool overflow;
const nbytes = mulu(len, T.sizeof, overflow);
if (overflow) assert(0);
return (cast(T*) malloc(nbytes))[0 .. len];
}
auto xform1 = trustedMalloc(r.length);

Expand Down