diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-10-27 17:48:34 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-10-27 17:48:34 +0200 |
commit | 8a7210593953077047d5515bf7cdc2ff4349b838 (patch) | |
tree | 65217fe5ae12f97a1685b1fcaae6f72acebba14a /common/tio.c | |
parent | 37d2dbf40565ee95d077ba101b1a1443528ecef2 (diff) |
fix memory leak in I/O module not free()ing allocated storage for file info on file close
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@462 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'common/tio.c')
-rw-r--r-- | common/tio.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/common/tio.c b/common/tio.c index ad34636..744fe5e 100644 --- a/common/tio.c +++ b/common/tio.c @@ -373,13 +373,16 @@ int tio_close(TFILE *fp) /* dump statistics to stderr */ fprintf(stderr,"DEBUG_TIO_STATS READ=%d WRITTEN=%d\n",fp->bytesread,fp->byteswritten); #endif /* DEBUG_TIO_STATS */ + /* close file descriptor */ + if (close(fp->fd)) + retv=-1; /* free any allocated buffers */ if (fp->readbuffer!=NULL) tio_buffer_free(fp->readbuffer); if (fp->writebuffer!=NULL) tio_buffer_free(fp->writebuffer); - /* close file descriptor */ - if (close(fp->fd)) - return -1; + /* free the tio struct itself */ + free(fp); + /* return the result of the earlier operations */ return retv; } |