|
@@ -330,11 +330,12 @@ void SDL_RemoveTrayEntry(SDL_TrayEntry *entry)
|
|
|
}
|
|
|
|
|
|
menu->nEntries--;
|
|
|
- SDL_TrayEntry ** new_entries = SDL_realloc(menu->entries, menu->nEntries * sizeof(SDL_TrayEntry *));
|
|
|
+ SDL_TrayEntry ** new_entries = SDL_realloc(menu->entries, (menu->nEntries + 1) * sizeof(SDL_TrayEntry *));
|
|
|
|
|
|
/* Not sure why shrinking would fail, but even if it does, we can live with a "too big" array */
|
|
|
if (new_entries) {
|
|
|
menu->entries = new_entries;
|
|
|
+ menu->entries[menu->nEntries] = NULL;
|
|
|
}
|
|
|
|
|
|
if (!DeleteMenu(menu->hMenu, (UINT) entry->id, MF_BYCOMMAND)) {
|
|
@@ -398,7 +399,7 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
|
|
|
entry->id = get_next_id();
|
|
|
}
|
|
|
|
|
|
- SDL_TrayEntry **new_entries = (SDL_TrayEntry **) SDL_realloc(menu->entries, (menu->nEntries + 1) * sizeof(SDL_TrayEntry **));
|
|
|
+ SDL_TrayEntry **new_entries = (SDL_TrayEntry **) SDL_realloc(menu->entries, (menu->nEntries + 2) * sizeof(SDL_TrayEntry **));
|
|
|
|
|
|
if (!new_entries) {
|
|
|
SDL_free(entry);
|
|
@@ -418,6 +419,7 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
|
|
|
}
|
|
|
|
|
|
new_entries[pos] = entry;
|
|
|
+ new_entries[menu->nEntries] = NULL;
|
|
|
|
|
|
if (label == NULL) {
|
|
|
InsertMenuW(menu->hMenu, windows_compatible_pos, MF_SEPARATOR | MF_BYPOSITION, entry->id, NULL);
|