summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tkPanedWindow.c68
-rw-r--r--tests/panedwindow.test23
3 files changed, 35 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index 8495b94..dc02abc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-06-19 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * tests/panedwindow.test:
+ * generic/tkPanedWindow.c: ensure that sash index is lower bounds
+ checked. [Bug #548727]
+
2002-06-19 Mo DeJong <mdejong@users.sourceforge.net>
* generic/tkClipboard.c (TkClipCleanup): Add code
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index 6091f91..be14e9c 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -12,70 +12,13 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkPanedWindow.c,v 1.3 2002/04/12 06:37:20 hobbs Exp $
+ * RCS: @(#) $Id: tkPanedWindow.c,v 1.4 2002/06/19 23:17:17 hobbs Exp $
*/
#include "tkPort.h"
#include "default.h"
#include "tkInt.h"
-#if ((TCL_MAJOR_VERSION > 8) || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 4))
-#define TCL_84
-#endif
-
-/*
- * We need to have TK_OPTION_CUSTOM, et al defined to compile with any
- * stubs-enable version of Tk, but we'll only allow the widget to
- * be created in 8.4+. These are taken from 8.4+ tk.h.
- */
-#ifndef TCL_84
-
-/*
- * Generating code for accessing these parts of the stub table when
- * compiling against a core older than 8.4a2 is a hassle because
- * we have to write up some macros hiding some very hackish pointer
- * arithmetics to get at these fields. We assume that pointer to
- * functions are always of the same size.
- */
-
-#define STUB_BASE ((char*)(&(tkStubsPtr->tk_GetAnchorFromObj))) /*field 200*/
-#define procPtrSize (sizeof(Tcl_DriverBlockModeProc *))
-#define IDX(n) (((n)-200) * procPtrSize)
-#define SLOT(n) (STUB_BASE + IDX(n))
-
-typedef Tk_Window (tk_CreateAnonymousWindow) _ANSI_ARGS_((Tcl_Interp * interp,
- Tk_Window parent, char * screenName)); /* 241 */
-#define Tk_CreateAnonymousWindow (*((tk_CreateAnonymousWindow**) (SLOT(241))))
-
-#define TK_OPTION_CUSTOM (TK_OPTION_END + 1)
-typedef int (Tk_CustomOptionSetProc) _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec,
- int offset, char *saveInternalPtr, int flags));
-typedef Tcl_Obj *(Tk_CustomOptionGetProc) _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset));
-typedef void (Tk_CustomOptionRestoreProc) _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin, char *internalPtr, char *saveInternalPtr));
-typedef void (Tk_CustomOptionFreeProc) _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin, char *internalPtr));
-
-typedef struct Tk_ObjCustomOption {
- char *name; /* Name of the custom option. */
- Tk_CustomOptionSetProc *setProc; /* Function to use to set a record's
- * option value from a Tcl_Obj */
- Tk_CustomOptionGetProc *getProc; /* Function to use to get a Tcl_Obj
- * representation from an internal
- * representation of an option. */
- Tk_CustomOptionRestoreProc *restoreProc; /* Function to use to restore a
- * saved value for the internal
- * representation. */
- Tk_CustomOptionFreeProc *freeProc; /* Function to use to free the internal
- * representation of an option. */
- ClientData clientData; /* Arbitrary one-word value passed to
- * the handling procs. */
-} Tk_ObjCustomOption;
-
-#endif
-
/* Flag values for "sticky"ness The 16 combinations subsume the packer's
* notion of anchor and fill.
*
@@ -253,6 +196,9 @@ static char * ComputeSlotAddress _ANSI_ARGS_((char *recordPtr, int offset));
static int PanedWindowIdentifyCoords _ANSI_ARGS_((PanedWindow *pwPtr,
Tcl_Interp *interp, int x, int y));
+#define ValidSashIndex(pwPtr, sash) \
+ (((sash) >= 0) && ((sash) < (pwPtr)->numSlaves))
+
static Tk_GeomMgr panedWindowMgrType = {
"panedwindow", /* name */
PanedWindowReqProc, /* requestProc */
@@ -1077,7 +1023,7 @@ PanedWindowSashCommand(pwPtr, interp, objc, objv)
return TCL_ERROR;
}
- if (sash >= pwPtr->numSlaves - 1) {
+ if (!ValidSashIndex(pwPtr, sash)) {
Tcl_ResetResult(interp);
Tcl_SetResult(interp, "invalid sash index", TCL_STATIC);
return TCL_ERROR;
@@ -1100,7 +1046,7 @@ PanedWindowSashCommand(pwPtr, interp, objc, objv)
return TCL_ERROR;
}
- if (sash >= pwPtr->numSlaves - 1) {
+ if (!ValidSashIndex(pwPtr, sash)) {
Tcl_ResetResult(interp);
Tcl_SetResult(interp, "invalid sash index", TCL_STATIC);
return TCL_ERROR;
@@ -1137,7 +1083,7 @@ PanedWindowSashCommand(pwPtr, interp, objc, objv)
return TCL_ERROR;
}
- if (sash >= pwPtr->numSlaves - 1) {
+ if (!ValidSashIndex(pwPtr, sash)) {
Tcl_ResetResult(interp);
Tcl_SetResult(interp, "invalid sash index", TCL_STATIC);
return TCL_ERROR;
diff --git a/tests/panedwindow.test b/tests/panedwindow.test
index 0177231..3a88c18 100644
--- a/tests/panedwindow.test
+++ b/tests/panedwindow.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: panedwindow.test,v 1.1 2002/02/22 02:41:17 hobbs Exp $
+# RCS: @(#) $Id: panedwindow.test,v 1.2 2002/06/19 23:17:17 hobbs Exp $
if {[info tclversion] < 8.4} {
puts "panedwindow requires Tk 8.4"
@@ -241,6 +241,27 @@ test panedwindow-6.7 {sash coord subcommand, sashes correctly placed} {
destroy .p .p.f .p.f2 .p.f3
set result
} [list 0 50]
+test panedwindow-6.8 {sash coord subcommand, errors} {
+ panedwindow .p
+ set result [list \
+ [catch {.p sash coord -1} msg] $msg \
+ [catch {.p sash coord 0} msg] $msg \
+ [catch {.p sash coord 1} msg] $msg \
+ ]
+ destroy .p
+ set result
+} [list 1 "invalid sash index" 1 "invalid sash index" 1 "invalid sash index"]
+test panedwindow-6.9 {sash coord subcommand, errors} {
+ panedwindow .p
+ .p add [frame .p.f]
+ set result [list \
+ [catch {.p sash coord -1} msg] $msg \
+ [catch {.p sash coord 0} msg] \
+ [catch {.p sash coord 1} msg] $msg \
+ ]
+ destroy .p
+ set result
+} [list 1 "invalid sash index" 0 1 "invalid sash index"]
test panedwindow-8.1 {sash mark subcommand, errors} {
panedwindow .p