]> git.sesse.net Git - vlc/commitdiff
dshow: remove dangerous alloca, fix charset and and invalid free
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>
Sat, 21 Mar 2009 17:55:16 +0000 (19:55 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 31 Mar 2009 15:22:00 +0000 (18:22 +0300)
Invalid free pointed out by xxcv.

modules/access/dshow/dshow.cpp

index a12a76c3480ce5f6524688a4075f8126d49b82de..6aa83b9087d0ceff028c155297056d851fd40b2c 100644 (file)
@@ -40,6 +40,7 @@
 #include <vlc_demux.h>
 #include <vlc_vout.h>
 #include <vlc_dialog.h>
+#include <vlc_charset.h>
 
 #include "common.h"
 #include "filter.h"
@@ -1205,16 +1206,8 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename,
             p_bag->Release();
             if( SUCCEEDED(hr) )
             {
-                int i_convert = WideCharToMultiByte(CP_ACP, 0, var.bstrVal,
-                        SysStringLen(var.bstrVal), NULL, 0, NULL, NULL);
-                char *p_buf = (char *)alloca( i_convert+1 ); p_buf[0] = 0;
-                WideCharToMultiByte( CP_ACP, 0, var.bstrVal,
-                        SysStringLen(var.bstrVal), p_buf, i_convert, NULL, NULL );
-                SysFreeString(var.bstrVal);
-                p_buf[i_convert] = '\0';
-
+                char *p_buf = FromWide( var.bstrVal );
                 string devname = string(p_buf);
-
                 free( p_buf) ;
 
                 int dup = 0;