[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: Re: WineHQ: Corrected PATCH to fix IPersistFile::Load() and associated
From: Mike McCormack <mike () codeweavers ! com>
Date: 2003-10-30 16:43:52
[Download RAW message or body]
Subhobroto Sinha wrote:
> Hello all
>
> I corrected my last patch after replacing everything
> C++ into C.
Great. It looks much better! There's just one last thing:
> + SHGetPathFromIDListA(This->pPidl,szTemp);
> + This->sPath=HeapAlloc( GetProcessHeap(), 0,(strlen(szTemp)+1)*sizeof(WCHAR));
> + dwBytesRead=(strlen(szTemp)+1);/*Just to hold the length of the string*/
> + MultiByteToWideChar(CP_ACP,0,szTemp,dwBytesRead,This->sPath,dwBytesRead);
> + TRACE("%s\n",debugstr_w(This->sPath));
The above code will calculate an incorrect length in some locales. You
should use:
len = MultiByteToWideChar(CP_ACP,0,szTemp,-1,NULL,0);
HeapAlloc( GetProcessHeap(), 0,len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP,0,szTemp,-1,This->sPath,len);
The (commonly made) assumption that one WCHAR is at most two multichar
bytes isn't correct.
Mike
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic