summaryrefslogtreecommitdiffstats
path: root/usr.bin/ranlib/build.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-01-09 05:59:04 +0000
committerdg <dg@FreeBSD.org>1995-01-09 05:59:04 +0000
commit8441e720c7e936ff93a9597309ec8312a4b15fe8 (patch)
tree33b7e494eaa588dcd85ae331639692844d0075c7 /usr.bin/ranlib/build.c
parent4969834bb25d688c299d10843d4c8f7cb2b61e29 (diff)
downloadFreeBSD-src-8441e720c7e936ff93a9597309ec8312a4b15fe8.zip
FreeBSD-src-8441e720c7e936ff93a9597309ec8312a4b15fe8.tar.gz
Fixed two bugs: some malloced space wasn't freed after it was no longer
needed and the file wasn't closed when the -t option was used. Originally by thomas@mathematik.uni-Bremen.de, but were incomplete. Submitted by: thomas@mathematik.uni-Bremen.de and myself
Diffstat (limited to 'usr.bin/ranlib/build.c')
-rw-r--r--usr.bin/ranlib/build.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c
index 12a6dc6..ff745be 100644
--- a/usr.bin/ranlib/build.c
+++ b/usr.bin/ranlib/build.c
@@ -220,7 +220,7 @@ bad1: (void)lseek(rfd, r_off, SEEK_SET);
static void
symobj()
{
- register RLIB *rp;
+ register RLIB *rp, *rpnext;
struct ranlib rn;
off_t ransize;
long size, stroff;
@@ -272,9 +272,14 @@ symobj()
error(tname);
/* Write out the string table. */
- for (rp = rhead; rp; rp = rp->next)
+ for (rp = rhead; rp; rp = rpnext) {
if (!fwrite(rp->sym, rp->symlen, 1, fp))
error(tname);
+ rpnext = rp->next;
+ free(rp->sym);
+ free(rp);
+ }
+ rhead = NULL;
if (pad && !fwrite(&pad, sizeof(pad), 1, fp))
error(tname);
OpenPOWER on IntegriCloud