summaryrefslogtreecommitdiffstats
path: root/generic/tkWindow.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-02-27 01:26:51 (GMT)
committerhobbs <hobbs>2002-02-27 01:26:51 (GMT)
commit9c3d7b330c6545c3c8c5e1d0d7b5edc45d819e3d (patch)
treee9444b3be73e0c6546dfdfbe1f63f8a113830872 /generic/tkWindow.c
parent86764e54e982f3d9898fcb2f0fc0561bda497a49 (diff)
downloadtk-9c3d7b330c6545c3c8c5e1d0d7b5edc45d819e3d.zip
tk-9c3d7b330c6545c3c8c5e1d0d7b5edc45d819e3d.tar.gz
tk-9c3d7b330c6545c3c8c5e1d0d7b5edc45d819e3d.tar.bz2
* generic/tkWindow.c (Tk_MainWindow, Tk_GetNumMainWindows):
protect against being called before Tcl stubs are init'ed. [Bug #220916] (porter)
Diffstat (limited to 'generic/tkWindow.c')
-rw-r--r--generic/tkWindow.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 0c82898..7975b54 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.42 2002/02/22 02:41:17 hobbs Exp $
+ * RCS: @(#) $Id: tkWindow.c,v 1.43 2002/02/27 01:26:51 hobbs Exp $
*/
#include "tkPort.h"
@@ -2503,8 +2503,18 @@ Tk_MainWindow(interp)
* reporting also. */
{
TkMainInfo *mainPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ ThreadSpecificData *tsdPtr;
+
+ if (interp == NULL) {
+ return NULL;
+ }
+#ifdef USE_TCL_STUBS
+ if (tclStubsPtr == NULL) {
+ return NULL;
+ }
+#endif
+ tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (mainPtr = tsdPtr->mainWindowList; mainPtr != NULL;
mainPtr = mainPtr->nextPtr) {
@@ -2628,8 +2638,16 @@ OpenIM(dispPtr)
int
Tk_GetNumMainWindows()
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ ThreadSpecificData *tsdPtr;
+
+#ifdef USE_TCL_STUBS
+ if (tclStubsPtr == NULL) {
+ return 0;
+ }
+#endif
+
+ tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->numMainWindows;
}