From df16beef2394e43a851c02727b1544950cebee65 Mon Sep 17 00:00:00 2001 From: mdejong Date: Sat, 15 Jun 2002 21:06:07 +0000 Subject: * generic/tkWindow.c (Tk_DestroyWindow): Set the pathName component of a window to NULL after its memory has been deallocated to avoid a possible illegal memory access as a result of a call to Tk_PathName() on a Tk_Window structure of a window that has already been destroyed. [Tk bug 521946] --- ChangeLog | 9 +++++++++ generic/tkWindow.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a6ba6e2..c88e100 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2002-06-14 Mo DeJong + * generic/tkWindow.c (Tk_DestroyWindow): Set the pathName + component of a window to NULL after its memory has been + deallocated to avoid a possible illegal memory access + as a result of a call to Tk_PathName() on a Tk_Window + structure of a window that has already been destroyed. + [Tk bug 521946] + +2002-06-14 Mo DeJong + * generic/tkOption.c (Tk_GetOption): Allocate memory with ckalloc not malloc. This keeps Tk from erroring out when built with diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 6bee9fa..03addc0 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWindow.c,v 1.47 2002/06/15 00:21:42 hobbs Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.48 2002/06/15 21:06:07 mdejong Exp $ */ #include "tkPort.h" @@ -1401,6 +1401,13 @@ Tk_DestroyWindow(tkwin) (ClientData) winPtr->pathName); Tcl_DeleteHashEntry(Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, winPtr->pathName)); + /* + * The memory pointed to by pathName has been deallocated. + * Keep users from accessing it after the window has been + * destroyed by setting it to NULL. + */ + winPtr->pathName = NULL; + /* * Invalidate all objects referring to windows on this display. */ -- cgit v0.12