Uwe Bonnes : ntdll: Remove spaces at end of name in import_dll.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Feb 21 05:04:47 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 19e29d6035570ef98f34dadcc8073a7e1e849f7f
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=19e29d6035570ef98f34dadcc8073a7e1e849f7f

Author: Uwe Bonnes <bon at elektron.ikp.physik.tu-darmstadt.de>
Date:   Mon Feb 20 14:08:26 2006 +0100

ntdll: Remove spaces at end of name in import_dll.

---

 dlls/ntdll/loader.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 00817ff..e5a9236 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -449,7 +449,7 @@ static WINE_MODREF *import_dll( HMODULE 
     IMAGE_THUNK_DATA *thunk_list;
     WCHAR buffer[32];
     const char *name = get_rva( module, descr->Name );
-    DWORD len = strlen(name) + 1;
+    DWORD len = strlen(name);
     PVOID protect_base;
     SIZE_T protect_size = 0;
     DWORD protect_old;
@@ -460,16 +460,20 @@ static WINE_MODREF *import_dll( HMODULE 
     else
         import_list = thunk_list;
 
-    if (len * sizeof(WCHAR) <= sizeof(buffer))
+    while (len && name[len-1] == ' ') len--;  /* remove trailing spaces */
+
+    if (len * sizeof(WCHAR) < sizeof(buffer))
     {
         ascii_to_unicode( buffer, name, len );
+        buffer[len] = 0;
         status = load_dll( load_path, buffer, 0, &wmImp );
     }
     else  /* need to allocate a larger buffer */
     {
-        WCHAR *ptr = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+        WCHAR *ptr = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
         if (!ptr) return NULL;
         ascii_to_unicode( ptr, name, len );
+        ptr[len] = 0;
         status = load_dll( load_path, ptr, 0, &wmImp );
         RtlFreeHeap( GetProcessHeap(), 0, ptr );
     }




More information about the wine-cvs mailing list