diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-06-25 23:10:07 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-06-25 23:10:07 +0000 |
commit | 759aafa007c42dce044800863455ad6048ed0ba5 (patch) | |
tree | ac041e727b0ca0fe197912f3920fd1117a4d75d0 | |
parent | 88a8ca5c8de86f1f3e5b43a490e0e70c6b456072 (diff) | |
download | plan9front-759aafa007c42dce044800863455ad6048ed0ba5.tar.xz |
rc: skip arguments to Xsrcline, Xsrcfile in codefree
We weren't correctly skipping the location operators
in codefree. This would mostly be work, but sometimes
you'd get unlucky and have one of the argmuents mismatch,
and that would lead to an invalid free.
This correctly skips the args in codefree.
-rw-r--r-- | sys/src/cmd/rc/code.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/src/cmd/rc/code.c b/sys/src/cmd/rc/code.c index 89cc43183..8e0142997 100644 --- a/sys/src/cmd/rc/code.c +++ b/sys/src/cmd/rc/code.c @@ -181,7 +181,7 @@ outcode(tree *t, int eflag) emits(fnstr(c1)); if((f = curfile(runq)) != nil){ emitf(Xsrcfile); - emits(strdup(f)); + emits(estrdup(f)); } emitf(Xsrcline); emiti(runq->lexline); @@ -486,10 +486,11 @@ codefree(code *cp) || p->f==Xrdwr || p->f==Xasync || p->f==Xbackq || p->f==Xcase || p->f==Xfalse || p->f==Xfor || p->f==Xjump + || p->f==Xsrcline || p->f==Xsubshell || p->f==Xtrue) p++; else if(p->f==Xdup || p->f==Xpipefd) p+=2; else if(p->f==Xpipe) p+=4; - else if(p->f==Xglobs) free(p[1].s), p+=2; + else if(p->f==Xglobs || p->f==Xsrcfile) free(p[1].s), p+=2; else if(p->f==Xword || p->f==Xdelhere) free((++p)->s); else if(p->f==Xfn){ free(p[2].s); |