mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
tabbed: eliminate double-free on error path
This commit is contained in:
parent
34b6cc12ec
commit
adc7313a4d
@ -164,20 +164,18 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
|||||||
nt->leftmost = nt->selected = NULL;
|
nt->leftmost = nt->selected = NULL;
|
||||||
nt->tabcount = 0;
|
nt->tabcount = 0;
|
||||||
nt->sepcols = 0;
|
nt->sepcols = 0;
|
||||||
memcpy(&nt->opts, topts, sizeof(*topts));
|
|
||||||
nt->opts.separator = NULL;
|
nt->opts.separator = NULL;
|
||||||
nt->opts.selchan = topts->selchan;
|
nt->opts.selchan = topts->selchan;
|
||||||
nt->opts.hdrchan = topts->hdrchan;
|
nt->opts.hdrchan = topts->hdrchan;
|
||||||
nt->opts.sepchan = topts->sepchan;
|
nt->opts.sepchan = topts->sepchan;
|
||||||
nt->opts.flags = topts->flags;
|
nt->opts.flags = topts->flags;
|
||||||
if(topts->separator){
|
if(topts->separator){
|
||||||
if((nt->opts.separator = strdup(topts->separator)) == NULL){
|
if((nt->sepcols = ncstrwidth(topts->separator, NULL, NULL)) < 0){
|
||||||
logerror("Couldn't allocate nctabbed separator");
|
logerror("Separator string contains illegal characters");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if((nt->sepcols = ncstrwidth(nt->opts.separator, NULL, NULL)) < 0){
|
if((nt->opts.separator = strdup(topts->separator)) == NULL){
|
||||||
logerror("Separator string contains illegal characters");
|
logerror("Couldn't allocate nctabbed separator");
|
||||||
free(nt->opts.separator);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user