Skip to content

Commit

Permalink
fix: Crash in GUI dialog due to invalid free
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcheung committed Dec 14, 2023
1 parent ea6dccc commit d7d68c6
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/utils-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ static PSID sid = NULL;
void
gui_message (const char *message)
{
gunichar2 *title = L"This is a command line application";
gunichar2 *body = g_utf8_to_utf16 (message, -1, NULL, NULL, NULL);
wchar_t *title = L"This is a command line application";
wchar_t *body = (wchar_t *) g_utf8_to_utf16 (
message, -1, NULL, NULL, NULL);

if (body == NULL)
body = g_utf8_to_utf16 ("(Failure to display help)",
-1, NULL, NULL, NULL);
if (body)
{
MessageBoxW (NULL, body, title,
MB_OK | MB_ICONINFORMATION | MB_TOPMOST);
g_free (body);
return;
}

MessageBoxW (NULL, (LPCWSTR) body, (LPCWSTR) title,
body = L"(Failure to display help)";
MessageBoxW (NULL, body, title,
MB_OK | MB_ICONINFORMATION | MB_TOPMOST);
g_free (title);
g_free (body);
return;
}


Expand Down

0 comments on commit d7d68c6

Please sign in to comment.