gtk: toolbar: Handle snprintf error

This commit is contained in:
Michael Drake 2022-10-22 21:58:21 +01:00 committed by Michael Drake
parent a584c6bb3b
commit 836b5b6126
1 changed files with 8 additions and 1 deletions

View File

@ -673,15 +673,22 @@ nsgtk_toolbar_customisation_save(struct nsgtk_toolbar *tb)
for (location = BACK_BUTTON;
location < PLACEHOLDER_BUTTON;
location++) {
int written;
itemid = itemid_from_location(tb, location);
if (itemid == PLACEHOLDER_BUTTON) {
/* no more filled locations */
break;
}
start += snprintf(start,
written = snprintf(start,
orderlen - (start - order),
"%s/",
tb->items[itemid].name);
if ((written < 0) ||
(written >= orderlen - (start - order))) {
free(order);
return NSERROR_UNKNOWN;
}
start += written;
if ((start - order) >= orderlen) {
break;