Fix potential 'divide-by-zero' in our UI fitting code.

Reported by coverity, better fix even if highly unlikely to happen...
This commit is contained in:
Bastien Montagne 2017-07-28 10:56:41 +02:00
parent 304e5541cb
commit 38eabcb858
1 changed files with 4 additions and 2 deletions

View File

@ -194,8 +194,9 @@ static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_
static int ui_item_fit(int item, int pos, int all, int available, bool is_last, int alignment, float *extra_pixel)
{
/* available == 0 is unlimited */
if (available == 0)
if (ELEM(0, available, all)) {
return item;
}
if (all > available) {
/* contents is bigger than available space */
@ -218,8 +219,9 @@ static int ui_item_fit(int item, int pos, int all, int available, bool is_last,
return (int)width;
}
}
else
else {
return item;
}
}
}