summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-10-19 12:08:24 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-10-19 12:08:24 +0000
commit1cd8295263661419654a2a8f37669ea8c62d3024 (patch)
treed8c02acb1f6f11bbc2d676acc301e9433659b855 /perlio.c
parent7adf2bcde9c5ba579260d057a84eb3974c2ee704 (diff)
downloadperl-1cd8295263661419654a2a8f37669ea8c62d3024.tar.gz
Memory leak fix, by Jarkko
p4raw-id: //depot/perl@29050
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/perlio.c b/perlio.c
index 703085b11a..6434a9bb16 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2397,6 +2397,27 @@ PerlIO_cleanup(pTHX)
PerlIO_list_free(aTHX_ PL_def_layerlist);
PL_def_layerlist = NULL;
}
+#ifdef USE_THREADS
+ MUTEX_UNLOCK(&PerlIO_mutex);
+#endif
+ if (PL_perlio_fd_refcnt_size /* Assuming initial size of zero. */
+ && PL_perlio_fd_refcnt) {
+#ifdef PERL_TRACK_MEMPOOL
+ Malloc_t ptr = (Malloc_t)((char*)PL_perlio_fd_refcnt-sTHX);
+ struct perl_memory_debug_header *const header
+ = (struct perl_memory_debug_header *)ptr;
+ /* Only the thread that allocated us can free us. */
+ if (header->interpreter == aTHX)
+#endif
+ {
+ Safefree(PL_perlio_fd_refcnt);
+ PL_perlio_fd_refcnt = NULL;
+ PL_perlio_fd_refcnt_size = 0;
+ }
+ }
+#ifdef USE_THREADS
+ MUTEX_UNLOCK(&PerlIO_mutex);
+#endif
}