From 79656a80df9a58093c6f1e20c0ede83b99a543bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 19 Dec 2016 16:16:50 +0100 Subject: [PATCH] Fix safety error on Windows. --- source/vibe/core/file.d | 11 +++++++---- source/vibe/core/net.d | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/vibe/core/file.d b/source/vibe/core/file.d index 1b3aafb..fb8aa07 100644 --- a/source/vibe/core/file.d +++ b/source/vibe/core/file.d @@ -142,10 +142,13 @@ FileStream createTempFile(string suffix = null) { version(Windows){ import std.conv : to; - char[L_tmpnam] tmp; - tmpnam(tmp.ptr); - auto tmpname = to!string(tmp.ptr); - if( tmpname.startsWith("\\") ) tmpname = tmpname[1 .. $]; + string tmpname; + () @trusted { + char[L_tmpnam] tmp; + tmpnam(tmp.ptr); + tmpname = to!string(tmp.ptr); + } (); + if (tmpname.startsWith("\\")) tmpname = tmpname[1 .. $]; tmpname ~= suffix; return openFile(tmpname, FileMode.createTrunc); } else { diff --git a/source/vibe/core/net.d b/source/vibe/core/net.d index 8577894..19ed62d 100644 --- a/source/vibe/core/net.d +++ b/source/vibe/core/net.d @@ -194,7 +194,7 @@ NetworkAddress anyAddress() struct NetworkAddress { import std.socket : Address; - version (Windows) import std.c.windows.winsock; + version (Windows) import core.sys.windows.winsock2; else import core.sys.posix.netinet.in_; @safe: