[vlc-commits] Skins2: simpler and more correct code for SHFileOperation since wcsncpy padds NULL

Jean-Baptiste Kempf git at videolan.org
Mon Jan 28 00:44:24 CET 2013


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jan 28 00:38:04 2013 +0100| [916c06479a773fee4f6f1fe0df3a7f0cf6a622c5] | committer: Jean-Baptiste Kempf

Skins2: simpler and more correct code for SHFileOperation since wcsncpy padds NULL

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=916c06479a773fee4f6f1fe0df3a7f0cf6a622c5
---

 modules/gui/skins2/win32/win32_factory.cpp |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 81bc68a..ea76147 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -482,9 +482,8 @@ void Win32Factory::rmDir( const string &rPath )
     LPWSTR dir_temp = ToWide( rPath.c_str() );
     size_t len = wcslen( dir_temp );
 
-    LPWSTR dir = (wchar_t *)malloc( (len + 1) * sizeof (wchar_t) );
-    wcsncpy( dir, dir_temp, len );
-    dir[len] = '\0';
+    LPWSTR dir = (wchar_t *)malloc( (len + 2) * sizeof (wchar_t) );
+    wcsncpy( dir, dir_temp, len + 2);
 
     SHFILEOPSTRUCTW file_op = {
         NULL,



More information about the vlc-commits mailing list