Skip to content

Commit e9b6da8

Browse files
Yundi339Copilot
andauthored
Quality: Fix malloc null-check per Cppcheck warning
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 531e289 commit e9b6da8

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/tray_windows.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ static HMENU _tray_menu(struct tray_menu *m, UINT *id) {
117117
// Convert UTF-8 text to UTF-16 (wide string)
118118
int wide_size = MultiByteToWideChar(CP_UTF8, 0, m->text, -1, NULL, 0);
119119
wchar_t *wide_text = (wchar_t *) malloc(wide_size * sizeof(wchar_t));
120+
if (wide_text == NULL) {
121+
DestroyMenu(hmenu);
122+
return NULL;
123+
}
120124
MultiByteToWideChar(CP_UTF8, 0, m->text, -1, wide_text, wide_size);
121125

122126
item.dwTypeData = wide_text;

0 commit comments

Comments
 (0)