summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2005-06-23 22:07:11 (GMT)
committerdas <das>2005-06-23 22:07:11 (GMT)
commit303f648c3c4cd55009825a5e652f3586de1fe14c (patch)
tree1d362930614375fab5d69642e7266d48eb3548fc
parenta2624934f7bfed3014a67d435ff8c16dea6b3a8d (diff)
downloadtk-303f648c3c4cd55009825a5e652f3586de1fe14c.zip
tk-303f648c3c4cd55009825a5e652f3586de1fe14c.tar.gz
tk-303f648c3c4cd55009825a5e652f3586de1fe14c.tar.bz2
* generic/tkConsole.c: backport fix for bug 756840 & sync whitespace
changes from HEAD. * generic/tkConsole.c (TkConsolePrint): prevent potential NULL deref.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkConsole.c34
2 files changed, 31 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 27762b0..19c072e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
*** 8.4.11 TAGGED FOR RELEASE ***
+ * generic/tkConsole.c: backport fix for bug 756840 & sync whitespace
+ changes from HEAD.
+
+ * generic/tkConsole.c (TkConsolePrint): prevent potential NULL deref.
+
* macosx/tkMacOSXDefault.h: change ENTRY_BORDER defaults to from 5 to 2
to make default entry widgets in TkAqua look like in other aqua apps
(and have same border dimensions as other platforms). [Bug 1176610]
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index cfb9219..5233749 100644
--- a/generic/tkConsole.c
+++ b/generic/tkConsole.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: tkConsole.c,v 1.18.2.1 2005/06/03 15:25:01 dkf Exp $
+ * RCS: @(#) $Id: tkConsole.c,v 1.18.2.2 2005/06/23 22:07:13 das Exp $
*/
#include "tk.h"
@@ -36,7 +36,7 @@ typedef struct ConsoleInfo {
* command and that is fragile. [Bug 1016385]
*/
-#define TK_CONSOLE_INFO_KEY "tk::ConsoleInfo"
+#define TK_CONSOLE_INFO_KEY "tk::ConsoleInfo"
typedef struct ThreadSpecificData {
Tcl_Interp *gStdoutInterp;
@@ -346,7 +346,7 @@ Tk_CreateConsoleWindow(interp)
#else
static const char *initCmd = "source $tk_library/console.tcl";
#endif
-
+
consoleInterp = Tcl_CreateInterp();
if (consoleInterp == NULL) {
goto error;
@@ -601,9 +601,9 @@ ConsoleCmd(clientData, interp, argc, argv)
Tcl_Eval(consoleInterp, Tcl_DStringValue(&dString));
Tcl_DStringFree(&dString);
} else if ((c == 'h') && (strncmp(argv[1], "hide", length)) == 0) {
- Tcl_Eval(consoleInterp, "wm withdraw . ");
+ Tcl_Eval(consoleInterp, "wm withdraw .");
} else if ((c == 's') && (strncmp(argv[1], "show", length)) == 0) {
- Tcl_Eval(consoleInterp, "wm deiconify . ");
+ Tcl_Eval(consoleInterp, "wm deiconify .");
} else if ((c == 'e') && (strncmp(argv[1], "eval", length)) == 0) {
if (argc == 3) {
result = Tcl_Eval(consoleInterp, argv[2]);
@@ -652,6 +652,7 @@ InterpreterCmd(clientData, interp, argc, argv)
char c;
size_t length;
int result;
+ Tcl_Interp *consoleInterp;
Tcl_Interp *otherInterp;
if (argc < 2) {
@@ -662,6 +663,8 @@ InterpreterCmd(clientData, interp, argc, argv)
c = argv[1][0];
length = strlen(argv[1]);
+ consoleInterp = info->consoleInterp;
+ Tcl_Preserve((ClientData) consoleInterp);
otherInterp = info->interp;
Tcl_Preserve((ClientData) otherInterp);
if ((c == 'e') && (strncmp(argv[1], "eval", length)) == 0) {
@@ -679,6 +682,7 @@ InterpreterCmd(clientData, interp, argc, argv)
result = TCL_ERROR;
}
Tcl_Release((ClientData) otherInterp);
+ Tcl_Release((ClientData) consoleInterp);
return result;
}
@@ -704,6 +708,17 @@ ConsoleDeleteProc(clientData)
ClientData clientData;
{
ConsoleInfo *info = (ConsoleInfo *) clientData;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ /*
+ * Also need to null this out to prevent any further use.
+ *
+ * Fix [Bug #756840]
+ */
+ if (tsdPtr != NULL) {
+ tsdPtr->gStdoutInterp = NULL;
+ }
Tcl_DeleteInterp(info->consoleInterp);
info->consoleInterp = NULL;
@@ -737,7 +752,8 @@ ConsoleEventProc(clientData, eventPtr)
Tcl_Interp *consoleInterp;
if (eventPtr->type == DestroyNotify) {
- consoleInterp = info->consoleInterp;
+
+ consoleInterp = info->consoleInterp;
/*
* It is possible that the console interpreter itself has
@@ -746,7 +762,9 @@ ConsoleEventProc(clientData, eventPtr)
* gone, we do not have to do any work here.
*/
- if (consoleInterp != (Tcl_Interp *) NULL) {
+ if (consoleInterp == (Tcl_Interp *) NULL) {
+ return;
+ } else {
Tcl_Preserve((ClientData) consoleInterp);
Tcl_Eval(consoleInterp, "::tk::ConsoleExit");
Tcl_Release((ClientData) consoleInterp);
@@ -789,7 +807,7 @@ TkConsolePrint(interp, devId, buffer, size)
}
info = (ConsoleInfo *) Tcl_GetAssocData(interp, TK_CONSOLE_INFO_KEY, NULL);
- if (info->consoleInterp == NULL) {
+ if (info == NULL || info->consoleInterp == NULL) {
return;
}