[vlc-devel] [PATCH 2/3] unc: fix calling Wide Win32 API with UTF-8 strings

Steve Lhomme robux4 at ycbcr.xyz
Wed Jul 10 08:02:24 CEST 2019


---
 modules/access/unc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/access/unc.c b/modules/access/unc.c
index 3903643396..86d51c463b 100644
--- a/modules/access/unc.c
+++ b/modules/access/unc.c
@@ -69,9 +69,12 @@ static void Win32AddConnection(stream_t *access, const char *server,
         *delim = '\0';
 
     const char *msg;
-    net_resource.lpRemoteName = remote_name;
+    net_resource.lpRemoteName = ToWide(remote_name);
 
-    switch (WNetAddConnection2(&net_resource, pwd, user, 0))
+    wchar_t *wpwd  = pwd  ? ToWide(pwd)  : NULL;
+    wchar_t *wuser = user ? ToWide(user) : NULL;
+
+    switch (WNetAddConnection2(&net_resource, wpwd, wuser, 0))
     {
         case NO_ERROR:
             msg = "connected to %s";
@@ -83,6 +86,9 @@ static void Win32AddConnection(stream_t *access, const char *server,
         default:
             msg = "failed to connect to %s";
     }
+    free(net_resource.lpRemoteName);
+    free(wpwd);
+    free(wuser);
     msg_Dbg(access, msg, remote_name);
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list