diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-08-23 21:09:46 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-08-23 21:09:46 +0000 |
commit | eb33e843b84fbb6d20613f9bec9fa0013d61d7e3 (patch) | |
tree | 907e1a91ca6ca57f1742a6081e71d2fcd1f405a4 /bin/sh/mknodes.c | |
parent | 6852110b6488f38f8d6139d6265deb26f29d7a11 (diff) | |
download | src-eb33e843b84fbb6d20613f9bec9fa0013d61d7e3.tar.gz src-eb33e843b84fbb6d20613f9bec9fa0013d61d7e3.zip |
sh: Fix crash when undefining or redefining a currently executing function.
Add a reference count to function definitions.
Memory may leak if multiple SIGINTs arrive in interactive mode,
this will be fixed later by changing SIGINT handling.
PR: bin/137640
Notes
Notes:
svn path=/head/; revision=196483
Diffstat (limited to 'bin/sh/mknodes.c')
-rw-r--r-- | bin/sh/mknodes.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/sh/mknodes.c b/bin/sh/mknodes.c index f0afca6800c8..904f9f4092ac 100644 --- a/bin/sh/mknodes.c +++ b/bin/sh/mknodes.c @@ -248,8 +248,13 @@ output(char *file) fputs("\tstruct nodelist *next;\n", hfile); fputs("\tunion node *n;\n", hfile); fputs("};\n\n\n", hfile); - fputs("union node *copyfunc(union node *);\n", hfile); - fputs("void freefunc(union node *);\n", hfile); + fputs("struct funcdef {\n", hfile); + fputs("\tunsigned int refcount;\n", hfile); + fputs("\tunion node n;\n", hfile); + fputs("};\n\n\n", hfile); + fputs("struct funcdef *copyfunc(union node *);\n", hfile); + fputs("void reffunc(struct funcdef *);\n", hfile); + fputs("void unreffunc(struct funcdef *);\n", hfile); fputs(writer, cfile); while (fgets(line, sizeof line, patfile) != NULL) { |