Ver código fonte

Initialize invalid parent_{tray,entry} to NULL

The API states that the related functions must return NULL if the function
called (get the parent tray, or get the parent entry) is invalid for this
menu. Initialising the fields to NULL makes that API correct for Windows.
Semphris 1 ano atrás
pai
commit
354d2c390c
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      src/tray/windows/SDL_tray.c

+ 6 - 0
src/tray/windows/SDL_tray.c

@@ -304,6 +304,7 @@ SDL_TrayMenu *SDL_CreateTrayMenu(SDL_Tray *tray)
 
 
     tray->menu->hMenu = CreatePopupMenu();
     tray->menu->hMenu = CreatePopupMenu();
     tray->menu->parent_tray = tray;
     tray->menu->parent_tray = tray;
+    tray->menu->parent_entry = NULL;
 
 
     return tray->menu;
     return tray->menu;
 }
 }
@@ -395,6 +396,8 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
         return NULL;
         return NULL;
     }
     }
 
 
+    SDL_memset((void *) entry, 0, sizeof(*entry));
+
     wchar_t *label_w = NULL;
     wchar_t *label_w = NULL;
 
 
     if (label && (label_w = escape_label(label)) == NULL) {
     if (label && (label_w = escape_label(label)) == NULL) {
@@ -417,10 +420,13 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
             return NULL;
             return NULL;
         }
         }
 
 
+        SDL_memset((void *) entry->submenu, 0, sizeof(*entry->submenu));
+
         entry->submenu->hMenu = CreatePopupMenu();
         entry->submenu->hMenu = CreatePopupMenu();
         entry->submenu->nEntries = 0;
         entry->submenu->nEntries = 0;
         entry->submenu->entries = NULL;
         entry->submenu->entries = NULL;
         entry->submenu->parent_entry = entry;
         entry->submenu->parent_entry = entry;
+        entry->submenu->parent_tray = NULL;
 
 
         entry->id = (UINT_PTR) entry->submenu->hMenu;
         entry->id = (UINT_PTR) entry->submenu->hMenu;
     } else {
     } else {