Skip to content

Commit

Permalink
Fix a bug in first() and a crashbug in rest() related to changes in i…
Browse files Browse the repository at this point in the history
…ssue #1048.
  • Loading branch information
talvo committed Dec 28, 2016
1 parent fcf2472 commit 6b053db
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/funlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,10 @@ FUNCTION(fun_first)
as = parse_ansi_string(args[0]);
p = trim_space_sep(as->text, sep);
q = split_token(&p, sep);
safe_ansi_string(as, q - as->text, p - q - 1, buff, bp);
if (p)
safe_ansi_string(as, q - as->text, p - q - 1, buff, bp);
else
safe_ansi_string(as, q - as->text, as->len, buff, bp);
free_ansi_string(as);
} else {
p = trim_space_sep(args[0], sep);
Expand Down Expand Up @@ -1257,6 +1260,8 @@ FUNCTION(fun_rest)
p = as->text;
}
(void) split_token(&p, sep);
if (!p || !*p)
return;
if (as) {
safe_ansi_string(as, p - as->text, as->len, buff, bp);
free_ansi_string(as);
Expand Down Expand Up @@ -1324,7 +1329,7 @@ FUNCTION(fun_grab)

do {
r = split_token(&s, sep);
if (quick_wild(args[1], r)) {
if (r && quick_wild(args[1], r)) {
if (as) {
safe_ansi_string(as, r - as->text, s - r - 1, buff, bp);
free_ansi_string(as);
Expand Down

0 comments on commit 6b053db

Please sign in to comment.