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)); 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 -- By by ... Detlef