eliminate double-free of tpreserved

This commit is contained in:
nick black 2021-09-03 09:45:08 -04:00
parent e968b3972c
commit e1a1ac3497
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 3 additions and 2 deletions

View File

@ -1262,7 +1262,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
err:
logpanic("Alas, you will not be going to space today.\n");
fbuf_free(&ret->rstate.f);
if(ret->tcache.tpreserved){
if(ret->tcache.ttyfd >= 0 && ret->tcache.tpreserved){
(void)tcsetattr(ret->tcache.ttyfd, TCSAFLUSH, ret->tcache.tpreserved);
free(ret->tcache.tpreserved);
}

View File

@ -921,8 +921,9 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
err:
if(ti->tpreserved){
(void)tcsetattr(ti->ttyfd, TCSANOW, ti->tpreserved);
free(ti->tpreserved);
ti->tpreserved = NULL;
}
free(ti->tpreserved);
free(ti->esctable);
free(ti->termversion);
del_curterm(cur_term);