-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2014-11-06 22:17, schrieb Jonathan Vollebregt:
+static int reg_print_error(LSTATUS error_code)
As mentioned yesterday this doesn't need a return value.
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *)&message, 0, NULL);
reg_message(STRING_ERROR);
reg_printfW(error_string, error_code, message);
HeapFree(GetProcessHeap(), 0, message);
http://msdn.microsoft.com/en-us/library/windows/desktop/ms679351(v=vs.85).as... says FormatMessage uses LocalAlloc to allocate the buffer. You need to free it with LocalFree.
I don't know if we have any rule for checking the return value for FormatMessage here. You are already in an error printing codepath, and if you print an error every time printing an error fails you'll never stop. Otoh it seems questionable not to check the return value.