Matteo Bruni : d3dx9: Fix D3DXCompileShaderFromFileW.

Alexandre Julliard julliard at winehq.org
Wed Sep 8 13:32:13 CDT 2010


Module: wine
Branch: master
Commit: d6ead897e23322c10e0f4497fe83c53bdf1a5e27
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d6ead897e23322c10e0f4497fe83c53bdf1a5e27

Author: Matteo Bruni <matteo.mystral at gmail.com>
Date:   Wed Sep  8 16:07:07 2010 +0200

d3dx9: Fix D3DXCompileShaderFromFileW.

---

 dlls/d3dx9_36/shader.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
index 1ddcde7..a3648c2 100644
--- a/dlls/d3dx9_36/shader.c
+++ b/dlls/d3dx9_36/shader.c
@@ -423,7 +423,7 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(LPCWSTR filename,
                                           LPD3DXCONSTANTTABLE* constant_table)
 {
     void *buffer;
-    DWORD len;
+    DWORD len, filename_len;
     HRESULT hr;
     struct D3DXIncludeImpl includefromfile;
     char *filename_a;
@@ -437,13 +437,14 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(LPCWSTR filename,
         include = (LPD3DXINCLUDE)&includefromfile;
     }
 
-    filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
+    filename_len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
+    filename_a = HeapAlloc(GetProcessHeap(), 0, filename_len * sizeof(char));
     if (!filename_a)
     {
         UnmapViewOfFile(buffer);
         return E_OUTOFMEMORY;
     }
-    WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
+    WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, filename_len, NULL, NULL);
 
     hr = D3DCompile(buffer, len, filename_a, (D3D_SHADER_MACRO *)defines,
                     (ID3DInclude *)include, entrypoint, profile, flags, 0,




More information about the wine-cvs mailing list