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

Nikolay Sivov bunglehead at gmail.com
Mon Aug 7 13:55:43 CDT 2017


On 07.08.2017 20:41, Carlos Palminha wrote:
> 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 );
> 

This is still shorter than it is now:

sizeof(dllW) is 5 * sizeof(WCHAR) vs strlenW(dllW) * sizeof(WCHAR) == 4
* sizeof(WCHAR).



More information about the wine-devel mailing list