diff options
author | jilles <jilles@FreeBSD.org> | 2009-08-23 21:09:46 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2009-08-23 21:09:46 +0000 |
commit | 4a8e08a1103988b9e44d3ae9584cd654796998b1 (patch) | |
tree | 907e1a91ca6ca57f1742a6081e71d2fcd1f405a4 /bin/sh/mknodes.c | |
parent | f0ee7a159b9f49405e827b40fed36a844334c3ac (diff) | |
download | FreeBSD-src-4a8e08a1103988b9e44d3ae9584cd654796998b1.zip FreeBSD-src-4a8e08a1103988b9e44d3ae9584cd654796998b1.tar.gz |
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
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 f0afca6..904f9f4 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) { |