"Mikolaj Zalewski" mikolajz@google.com writes:
- buf = HeapAlloc(GetProcessHeap(), 0, size + 4);
- if ((err = RegQueryValueExW(hKey, szValue, 0, &type, (LPBYTE)buf, &size)) != 0)
goto failed;
- buf[size/2] = 0;
- buf[size/2 + 1] = 0;
Please use sizeof(WCHAR) instead of hardcoding values like 2 and 4.