Merge branch 'crash-in-url-mode-remove-duplicates'

Closes #627
This commit is contained in:
Daniel Eklöf 2021-07-11 11:30:31 +02:00
commit d22ba73c41
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 14 additions and 7 deletions

View file

@ -51,6 +51,8 @@
last column, and `tweak.allow-overflowing-double-width-glyphs=yes`.
* FD exhaustion when repeatedly entering/exiting URL mode with many
URLs.
* Double free of URL while removing duplicated and/or overlapping URLs
in URL mode (https://codeberg.org/dnkl/foot/issues/627).
### Security

View file

@ -264,6 +264,7 @@ struct url {
enum url_action action;
bool url_mode_dont_change_url_attr; /* Entering/exiting URL mode doesnt touch the cells attr.url */
bool osc8;
bool duplicate;
};
typedef tll(struct url) url_list_t;

View file

@ -470,16 +470,20 @@ remove_overlapping(url_list_t *urls, int cols)
*/
xassert(in->osc8 || out->osc8);
if (in->osc8) {
url_destroy(&outer->item);
tll_remove(*urls, outer);
} else {
url_destroy(&inner->item);
tll_remove(*urls, inner);
}
if (in->osc8)
outer->item.duplicate = true;
else
inner->item.duplicate = true;
}
}
}
tll_foreach(*urls, it) {
if (it->item.duplicate) {
url_destroy(&it->item);
tll_remove(*urls, it);
}
}
}
void