correct sloppy NULL checks, in interface code:

- uiPupMenuBegin was checking for NULL title but would still crash if it were NULL.
- now tag the function as 'nonnull' and remove NULL checks. make sure NULL isnt passed to it.
This commit is contained in:
2013-07-27 14:17:20 +00:00
parent 6aa001f48d
commit d7ff7ad3e9
3 changed files with 9 additions and 7 deletions

View File

@@ -327,7 +327,11 @@ typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
typedef struct uiPopupMenu uiPopupMenu;
struct uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
struct uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
;
void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);

View File

@@ -4944,7 +4944,6 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiPopupMenu *pup;
uiLayout *layout;
bool is_array, is_array_component;
const char *name;
uiStringInfo label = {BUT_GET_LABEL, NULL};
/* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/
@@ -4957,12 +4956,11 @@ static bool ui_but_menu(bContext *C, uiBut *but)
button_timers_tooltip_remove(C, but);
/* highly unlikely getting the label ever fails */
uiButGetStrInfo(C, but, &label, NULL);
name = label.strinfo;
pup = uiPupMenuBegin(C, name, ICON_NONE);
pup = uiPupMenuBegin(C, label.strinfo ? label.strinfo : "", ICON_NONE);
layout = uiPupMenuLayout(pup);
if (label.strinfo)
MEM_freeN(label.strinfo);

View File

@@ -2542,7 +2542,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
pup->block->handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
/* create title button */
if (title && title[0]) {
if (title[0]) {
char titlestr[256];
if (icon) {