Skip to content

Commit

Permalink
notcurses_core_init: call notcurses_stop_minimal() on error path
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Sep 2, 2021
1 parent dc0f90a commit ad87e8c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/lib/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ notcurses_stop_minimal(void* vnc){
ret = -1;
}
}
ret |= tcsetattr(nc->tcache.ttyfd, TCSAFLUSH, nc->tcache.tpreserved);
if(nc->tcache.tpreserved){
ret |= tcsetattr(nc->tcache.ttyfd, TCSAFLUSH, nc->tcache.tpreserved);
}
}
if((esc = get_escape(&nc->tcache, ESCAPE_RMKX)) && fbuf_emit(f, esc)){
ret = -1;
Expand Down Expand Up @@ -1257,12 +1259,8 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){

err:
logpanic("Alas, you will not be going to space today.\n");
notcurses_stop_minimal(ret);
fbuf_free(&ret->rstate.f);
if(ret->tcache.tpreserved){
(void)tcsetattr(ret->tcache.ttyfd, TCSAFLUSH, ret->tcache.tpreserved);
free(ret->tcache.tpreserved);
}
drop_signals(ret);
del_curterm(cur_term);
pthread_mutex_destroy(&ret->stats.lock);
pthread_mutex_destroy(&ret->pilelock);
Expand Down

0 comments on commit ad87e8c

Please sign in to comment.