diff options
author | jilles <jilles@FreeBSD.org> | 2014-03-26 20:43:40 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2014-03-26 20:43:40 +0000 |
commit | 270892ce0aa34981474cedfa90e120b5971c6e13 (patch) | |
tree | fbddad8551c3a2e6b6992b43332553c88006070a /bin/sh/alias.c | |
parent | 6ceec4444ddbcea29246cb67b83eff062485cdc3 (diff) | |
download | FreeBSD-src-270892ce0aa34981474cedfa90e120b5971c6e13.zip FreeBSD-src-270892ce0aa34981474cedfa90e120b5971c6e13.tar.gz |
sh: Fix possible memory leaks and double frees with unexpected SIGINT.
Diffstat (limited to 'bin/sh/alias.c')
-rw-r--r-- | bin/sh/alias.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/sh/alias.c b/bin/sh/alias.c index 9ebdcb5..21f3f44 100644 --- a/bin/sh/alias.c +++ b/bin/sh/alias.c @@ -180,6 +180,7 @@ printaliases(void) int i, j; struct alias **sorted, *ap; + INTOFF; sorted = ckmalloc(aliases * sizeof(*sorted)); j = 0; for (i = 0; i < ATABSIZE; i++) @@ -187,9 +188,13 @@ printaliases(void) if (*ap->name != '\0') sorted[j++] = ap; qsort(sorted, aliases, sizeof(*sorted), comparealiases); - for (i = 0; i < aliases; i++) + for (i = 0; i < aliases; i++) { printalias(sorted[i]); + if (int_pending()) + break; + } ckfree(sorted); + INTON; } int |