]> git.lizzy.rs Git - plan9front.git/commitdiff
fix heredoc crash
authorOri Bernstein <ori@eigenstate.org>
Mon, 9 Mar 2020 21:24:02 +0000 (14:24 -0700)
committerOri Bernstein <ori@eigenstate.org>
Mon, 9 Mar 2020 21:24:02 +0000 (14:24 -0700)
we emitted an error on heredoc tags, but we
continued on, and added a heredoc entry to
the list, with a tag that we couldn't handle.

when processing this heredoc, rc would segfault.

fix: don't add a heredoc to the list on error.

sys/src/cmd/rc/here.c

index 922911f80d7ae6fe5382052629996609b5a3b79a..3ee8d6395e5e18ceea10d1e1f1ad3efe9057faf1 100644 (file)
@@ -22,9 +22,13 @@ hexnum(char *p, int n)
 tree*
 heredoc(tree *tag)
 {
-       struct here *h = new(struct here);
-       if(tag->type!=WORD)
+       struct here *h;
+
+       if(tag->type!=WORD){
                yyerror("Bad here tag");
+               return nil;
+       }
+       h = new(struct here);
        h->next = 0;
        if(here)
                *ehere = h;