From a8ac6c3230544ef6ce40e973f040b489706d5ed2 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 15 Mar 2009 22:34:58 +0000 Subject: Fix [Bug 2687952] --- ChangeLog | 4 ++++ generic/tclThread.c | 10 ++++++---- generic/tclThreadStorage.c | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03361cd..a0ed390 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-03-15 Donal K. Fellows + * generic/tclThreadStorage.c (TSDTableDelete): [Bug 2687952]: Ensure + * generic/tclThread.c (Tcl_GetThreadData): that structures in + Tcl's TSD system are all freed. Use the correct matching allocator. + * generic/tclPosixStr.c (Tcl_SignalId,Tcl_SignalMsg): [Patch 1513655]: Added support for SIGINFO, which is present on BSD platforms. diff --git a/generic/tclThread.c b/generic/tclThread.c index a538316..314a4fb 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclThread.c,v 1.23 2009/02/10 23:09:06 nijtmans Exp $ + * RCS: @(#) $Id: tclThread.c,v 1.24 2009/03/15 22:34:59 dkf Exp $ */ #include "tclInt.h" @@ -88,8 +88,11 @@ Tcl_GetThreadData( result = TclThreadStorageKeyGet(keyPtr); if (result == NULL) { - result = ckalloc((size_t)size); - memset(result, 0, (size_t)size); + result = TclpSysAlloc((size_t) size, 0); + if (result == NULL) { + Tcl_Panic("unable to alloc %u bytes", (unsigned) size); + } + memset(result, 0, (size_t) size); TclThreadStorageKeySet(keyPtr, result); } #else /* TCL_THREADS */ @@ -133,7 +136,6 @@ TclThreadDataKeyGet( return *keyPtr; #endif /* TCL_THREADS */ } - /* *---------------------------------------------------------------------- diff --git a/generic/tclThreadStorage.c b/generic/tclThreadStorage.c index 1568998..adcf1d3 100644 --- a/generic/tclThreadStorage.c +++ b/generic/tclThreadStorage.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclThreadStorage.c,v 1.18 2008/11/29 12:18:35 dkf Exp $ + * RCS: @(#) $Id: tclThreadStorage.c,v 1.19 2009/03/15 22:34:59 dkf Exp $ */ #include "tclInt.h" @@ -110,6 +110,19 @@ static void TSDTableDelete( TSDTable *tsdTablePtr) { + sig_atomic_t i; + + for (i=0 ; iallocated ; i++) { + if (tsdTablePtr->tablePtr[i] != NULL) { + /* + * These values were allocated in Tcl_GetThreadData in tclThread.c + * and must now be deallocated or they will leak. + */ + + TclpSysFree((char *) tsdTablePtr->tablePtr[i]); + } + } + TclpSysFree(tsdTablePtr->tablePtr); TclpSysFree(tsdTablePtr); } -- cgit v0.12