[PATCH v2] ntdll: Fix wrong string size alloc when loading libraries

Carlos Palminha CARLOS.PALMINHA at synopsys.com
Mon Aug 7 12:41:35 CDT 2017


Fixed some nasty unhandled exceptions when loading libraries
that don't have .dll extension.

Problem was caused by wrong string size calculation.

v2: Now properly takes into account strlen * sizeof WCHAR

Signed-off-by: Carlos Palminha <palminha at synopsys.com>
---
 dlls/ntdll/loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index dd1f74c0fc..83dd6d378e 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2141,7 +2141,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
     if (!(ext = strrchrW( libname, '.')) || strchrW( ext, '/' ) || strchrW( ext, '\\'))
     {
         if (!(dllname = RtlAllocateHeap( GetProcessHeap(), 0,
-                                         (strlenW(libname) * sizeof(WCHAR)) + sizeof(dllW) )))
+                                         (strlenW(libname) * sizeof(WCHAR)) + (strlenW(dllW) * sizeof(WCHAR)) )))
             return STATUS_NO_MEMORY;
         strcpyW( dllname, libname );
         strcatW( dllname, dllW );
-- 
2.11.0




More information about the wine-patches mailing list