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
10 changes: 7 additions & 3 deletions compiler/src/dmd/link.d
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,13 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c
version (Windows)
{
// generate unique temporary file name for preprocessed output
const(char)* tmpname = tmpnam(null);
assert(tmpname);
const(char)[] ifilename = tmpname[0 .. strlen(tmpname) + 1];
char[MAX_PATH] tempDir = void;
char[MAX_PATH] tempFile = void;
if (GetTempPathA(MAX_PATH, tempDir.ptr) == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, but this should use the wide string API and convert the result to UTF8 to avoid bad encoding of the user home directory if it contains non-ascii characters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that.

return STATUS_FAILED;
if (GetTempFileNameA(tempDir.ptr, "dmd", 0, tempFile.ptr) == 0)
return STATUS_FAILED;
const(char)[] ifilename = tempFile[0 .. strlen(tempFile.ptr) + 1];
ifilename = xarraydup(ifilename);
const(char)[] output = ifilename;

Expand Down
Loading