From c1f87215c2cad528ea7a4a7617b71a78fa22e077 Mon Sep 17 00:00:00 2001 From: hobbs Date: Sat, 5 Feb 2000 11:11:51 +0000 Subject: * unix/tkUnixScale.c (TkpDestroyScale): changed ckfree to Tcl_EventuallyFree to behave with Tcl_Preserve in TkpDisplayScale (prevents possible segfault). --- ChangeLog | 6 ++++++ unix/tkUnixScale.c | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc89b5c..519734c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-02-05 Jeff Hobbs + + * unix/tkUnixScale.c (TkpDestroyScale): changed ckfree to + Tcl_EventuallyFree to behave with Tcl_Preserve in TkpDisplayScale + (prevents possible segfault). + 2000-02-03 Eric Melski * tests/text.test: diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index bafb887..5774cd7 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixScale.c,v 1.4 1999/12/22 20:01:26 hobbs Exp $ + * RCS: @(#) $Id: tkUnixScale.c,v 1.5 2000/02/05 11:11:56 hobbs Exp $ */ #include "tkScale.h" @@ -56,7 +56,9 @@ TkpCreateScale(tkwin) * * TkpDestroyScale -- * - * Destroy a TkScale structure. + * Destroy a TkScale structure. It's necessary to do this with + * Tcl_EventuallyFree to allow the Tcl_Preserve(scalePtr) to work + * as expected in TkpDisplayScale. (hobbs) * * Results: * None @@ -71,7 +73,7 @@ void TkpDestroyScale(scalePtr) TkScale *scalePtr; { - ckfree((char *) scalePtr); + Tcl_EventuallyFree((ClientData) scalePtr, TCL_DYNAMIC); } /* @@ -514,19 +516,18 @@ TkpDisplayScale(clientData) */ Tcl_Preserve((ClientData) scalePtr); - Tcl_Preserve((ClientData) interp); if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->commandPtr != NULL)) { + Tcl_Preserve((ClientData) interp); sprintf(string, scalePtr->format, scalePtr->value); - result = Tcl_VarEval(interp, Tcl_GetString(scalePtr->commandPtr), " ", string, (char *) NULL); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (command executed by scale)"); Tcl_BackgroundError(interp); } + Tcl_Release((ClientData) interp); } - Tcl_Release((ClientData) interp); scalePtr->flags &= ~INVOKE_COMMAND; if (scalePtr->flags & SCALE_DELETED) { Tcl_Release((ClientData) scalePtr); -- cgit v0.12