mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
common/file.d fix malloc check (#14536)
This commit is contained in:
parent
e319e71628
commit
e431c85202
1 changed files with 8 additions and 3 deletions
|
@ -144,9 +144,14 @@ struct FileMapping(Datum)
|
|||
import core.stdc.string : strlen;
|
||||
import core.stdc.stdlib : malloc;
|
||||
import core.stdc.string : memcpy;
|
||||
auto totalNameLength = filename.strlen() + 1;
|
||||
name = cast(char*) memcpy(malloc(totalNameLength), filename, totalNameLength);
|
||||
name || assert(0, "FileMapping: Out of memory.");
|
||||
const totalNameLength = filename.strlen() + 1;
|
||||
auto namex = cast(char*) malloc(totalNameLength);
|
||||
if (!namex)
|
||||
{
|
||||
fprintf(stderr, "FileMapping: Out of memory.");
|
||||
exit(1);
|
||||
}
|
||||
name = cast(char*) memcpy(namex, filename, totalNameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue