From 8a7210593953077047d5515bf7cdc2ff4349b838 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sat, 27 Oct 2007 15:48:34 +0000 Subject: 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 --- common/tio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'common/tio.c') 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; } -- cgit v1.2.3