[RESEND] regedit: Convert from WCHAR size to maximum required TCHAR size.

Bill Medland billmedland at shaw.ca
Wed Apr 4 14:51:33 CDT 2007


On Thu, 2007-05-04 at 02:18 +0900, Byeong-Sik Jeon wrote:
> Hi,
> 
> Currently regedit is not defined "UNICODE".
> 
> The point are "max_val_name_len", "valName", "valNameLen".
> Not max_val_size, valSize.
> 
> RegQueryInfoKey set the "max_val_name_len" to the size of the longest
> value name, in characters. This value is not required byte size. 
> 

but the call to HeapAlloc multiplies by sizeof TCHAR already.

> N character string:
> ==> w/  UNICODE, N WHAR string.
> ==> w/o UNICODE, N ~ 2N unsigned char string.
> 
> Please, test the CJK locale. and See the "IDS_NEWKEY, IDS_NEWVALUE" in
> Ja.rc or Ko.rc .
> If we create the registry "value name" in the empty registry key,
> we can't see any newly created reg value name.
> 
> Thanks.
> 
> Detlef Riekenberg wrote:
> > On Mi, 2007-04-04 at 10:36 +0900, Byeong-Sik Jeon wrote:
> > >  
> > > +    /* convert from WCHAR size to maximum required TCHAR size */
> > > +    max_val_name_len *= sizeof(WCHAR) / sizeof(TCHAR);
> > > +
> > >      valName = HeapAlloc(GetProcessHeap(), 0, max_val_name_len *
> > > sizeof(TCHAR));

See!

> > >      valBuf = HeapAlloc(GetProcessHeap(), 0, max_val_size);
> > >      if (RegQueryValueEx(hKey, NULL, NULL, &valType, valBuf, &valSize)
> > > == ERROR_FILE_NOT_FOUND) { 
> > 
> > This looks wrong to me:
> > TCHAR is WCHAR, when compiled with UNICODE, otherwise TCHAR is CHAR
> > The code does already handle the different character-size
> > in HeapAlloc for varName.
> > 
> > When the app must handle the case, that 
> > sizeof(string) can be > "strlen(string) + sizeof(0)",
> > then we should convert the app to use UNICODE everywhere.
> > 
> > For the last quoted line, valSize is not initialized!
> > (RegQueryInfoKey wrote the result to max_val_size)
> > 
> > Just checked Coverity: not detected
> > 
> > 
> 
> 
> 




More information about the wine-devel mailing list