summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2022-02-03 20:53:52 (GMT)
committerfvogel <fvogelnew1@free.fr>2022-02-03 20:53:52 (GMT)
commit647a52cc655f5f438998745138fd070d16413c59 (patch)
treea00f97db48f3b3974eb081eb8a2f2cf87c144a5b
parentfaf7267ef33d043ebe467ad0b6aede6c4b784e99 (diff)
parentc9044b394b99a5e44d34053d1aeebc71c28be003 (diff)
downloadtk-647a52cc655f5f438998745138fd070d16413c59.zip
tk-647a52cc655f5f438998745138fd070d16413c59.tar.gz
tk-647a52cc655f5f438998745138fd070d16413c59.tar.bz2
Fix [3fefb364e2]: crash in ttk::combobox current with empty combobox.
-rw-r--r--generic/ttk/ttkEntry.c12
-rw-r--r--tests/ttk/combobox.test5
2 files changed, 16 insertions, 1 deletions
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 1d8137b..f7ee557 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1849,10 +1849,20 @@ static int ComboboxCurrentCommand(
switch (index) {
case INDEX_END:
/* "end" index */
+ if (nValues <= 0) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "index \"end\" out of range"));
+ Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
+ return TCL_ERROR;
+ }
currentIndex = nValues - 1;
break;
+ default:
+ Tcl_Panic("Unknown named index");
+ return TCL_ERROR;
}
- } else {
+
+ } else {
/*
* The index should be just an integer.
diff --git a/tests/ttk/combobox.test b/tests/ttk/combobox.test
index eee0622..bd2dce6 100644
--- a/tests/ttk/combobox.test
+++ b/tests/ttk/combobox.test
@@ -60,6 +60,11 @@ test combobox-2.7 {current -- set to 0 index when empty [bug 924835c36d]} -body
.cb current 0
} -returnCodes error -result {Index 0 out of range}
+test combobox-2.8 "current -- set to end index in an empty combobox" -body {
+ .cb configure -values {}
+ .cb current end
+} -returnCodes error -result {index "end" out of range}
+
test combobox-2.end "Cleanup" -body { destroy .cb }
test combobox-3 "Read postoffset value dynamically from current style" -body {