From d4159c07943ed7e784782c9fa621a039632e57f0 Mon Sep 17 00:00:00 2001 From: hobbs Date: Fri, 11 Feb 2005 20:34:53 +0000 Subject: * win/tkWinWm.c (TkWinGetIcon): fix toplevel retrieval for determining icon ref (potential crash). [Bug 1105738] --- ChangeLog | 4 ++++ win/tkWinWm.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f7d4a2..82e098a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-02-11 Jeff Hobbs + * win/tkWinWm.c (TkWinGetIcon): fix toplevel retrieval for + determining icon ref (potential crash). [Bug 1105738] + * generic/tkCanvBmap.c (ConfigureBitmap, ComputeBitmapBbox): Fixed possible crash with disabled bmap and bbox handling [Bug 1119460] (BitmapToPostscript): made aware of various bitmap types @@ -40,6 +43,7 @@ Keith Nash 2005-01-14 Joe English + * unix/tkUnixWm.c: Sync with CVS HEAD (r1.47): Fixes: #959973 "wm title bug" (support Unicode titles) Fixes: #742882 "Potential division by zero in gridded wm geometry" diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 8fd60a9..de56e6e 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.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: tkWinWm.c,v 1.54.2.17 2005/01/04 01:28:51 hobbs Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.54.2.18 2005/02/11 20:35:09 hobbs Exp $ */ #include "tkWinInt.h" @@ -1130,9 +1130,8 @@ WinSetIcon(interp, titlebaricon, tkw) *---------------------------------------------------------------------- */ HICON -TkWinGetIcon(Tk_Window tkw, DWORD iconsize) +TkWinGetIcon(Tk_Window tkwin, DWORD iconsize) { - TkWindow *winPtr; WmInfo *wmPtr; HICON icon; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -1145,17 +1144,19 @@ TkWinGetIcon(Tk_Window tkw, DWORD iconsize) return GetIcon(tsdPtr->iconPtr, iconsize); } - if (Tk_WindowId(tkw) == None) { - Tk_MakeWindowExist(tkw); + /* ensure we operate on the toplevel, that has the icon refs */ + while (!Tk_IsTopLevel(tkwin)) { + tkwin = Tk_Parent(tkwin); + if (tkwin == NULL) { + return NULL; + } } - winPtr = (TkWindow *)tkw; - if (!(Tk_IsTopLevel(tkw))) { - winPtr = GetTopLevel(Tk_GetHWND(Tk_WindowId(tkw))); + if (Tk_WindowId(tkwin) == None) { + Tk_MakeWindowExist(tkwin); } - /* We must get the window's wrapper, not the window itself */ - wmPtr = winPtr->wmInfoPtr; + wmPtr = ((TkWindow *) tkwin)->wmInfoPtr; if (wmPtr->iconPtr != NULL) { /* * return window toplevel icon -- cgit v0.12