Merge branch 'osc8-mem-leak'

Closes #495
This commit is contained in:
Daniel Eklöf 2021-05-08 20:27:46 +02:00
commit 2f01ecbadb
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 11 additions and 6 deletions

View file

@ -81,6 +81,9 @@
resulting in PGO build failures.
* Wrong colors in the 256-color cube
(https://codeberg.org/dnkl/foot/issues/479).
* Memory leak triggered by “opening” an OSC-8 URI and then resetting
the terminal without closing the URI
(https://codeberg.org/dnkl/foot/issues/495).
### Security

View file

@ -1649,13 +1649,13 @@ term_reset(struct terminal *term, bool hard)
term->scroll_region.start = 0;
term->scroll_region.end = term->rows;
free(term->vt.osc.data);
memset(&term->vt, 0, sizeof(term->vt));
term->vt.state = 0; /* GROUND */
term->vt.osc8.begin = (struct coord){-1, -1};
free(term->vt.osc8.uri);
term->vt.osc8.uri = NULL;
free(term->vt.osc.data);
term->vt = (struct vt){
.state = 0, /* STATE_GROUND */
.osc8 = {.begin = (struct coord){-1, -1}},
};
if (term->grid == &term->alt) {
term->grid = &term->normal;
@ -3070,6 +3070,8 @@ term_osc8_open(struct terminal *term, uint64_t id, const char *uri)
term_osc8_close(term);
}
xassert(term->vt.osc8.uri == NULL);
term->vt.osc8.begin = (struct coord){
.col = term->grid->cursor.point.col,
.row = grid_row_absolute(term->grid, term->grid->cursor.point.row),