[vlc-devel] commit: dshow: remove dangerous alloca, fix charset and and invalid free ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Mar 31 17:44:07 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi.denis-courmont at nokia.com> | Sat Mar 21 19:55:16 2009 +0200| [6b72c1b0aafc1733a7fcb6f6c722338a625bdfd9] | committer: Rémi Denis-Courmont 

dshow: remove dangerous alloca, fix charset and and invalid free

Invalid free pointed out by xxcv.

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

 modules/access/dshow/dshow.cpp |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp
index a12a76c..6aa83b9 100644
--- a/modules/access/dshow/dshow.cpp
+++ b/modules/access/dshow/dshow.cpp
@@ -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;




More information about the vlc-devel mailing list