Prevent a segfault when the parameter to command 'repeat' is given,

but cannot be evaluetd to a number.
This commit is contained in:
Holger Vogt 2022-03-21 16:53:37 +01:00
parent 7de6d65e6d
commit ae3d171d91
1 changed files with 7 additions and 2 deletions

View File

@ -716,13 +716,18 @@ cp_evloop(char *string)
if (!wlist->wl_next) {
cend[stackp]->co_numtimes = -1;
} else {
char *s;
char *s = "1";
double val;
struct wordlist *t; /*CDHW*/
/*CDHW wlist = cp_variablesubst(cp_bquote(cp_doglob(wl_copy(wlist)))); Wrong order? Leak? CDHW*/
t = cp_doglob(cp_bquote(cp_variablesubst(wl_copy(wlist)))); /*CDHW leak from cp_doglob? */
s = t->wl_next->wl_word;
if (!t->wl_next) {
fprintf(cp_err, "Error: Undefined number after command 'repeat', assume 1\n");
}
else
s = t->wl_next->wl_word;
if (ft_numparse(&s, FALSE, &val) > 0) {
/* Can be converted to int */