summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2023-06-06 20:22:55 (GMT)
committerfvogel <fvogelnew1@free.fr>2023-06-06 20:22:55 (GMT)
commit274946bac908c5520729223647320fb2c25e8a1d (patch)
treea1aaa48dbc956cfad861e96b698841bcf60131ef
parent36ecdb06871a56957e1ccb3b2b42fcf80a6884b0 (diff)
parentd784654c95274c471e4319ed0d7e42adaceac453 (diff)
downloadtk-274946bac908c5520729223647320fb2c25e8a1d.zip
tk-274946bac908c5520729223647320fb2c25e8a1d.tar.gz
tk-274946bac908c5520729223647320fb2c25e8a1d.tar.bz2
Fix [a418aafa76]: Bogus @x,y indices are accepted for menu entries.
-rw-r--r--generic/tkMenu.c5
-rw-r--r--tests/menu.test46
2 files changed, 49 insertions, 2 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index b4c6473..fbf4e33 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -2956,10 +2956,13 @@ GetIndexFromCoords(
x = y;
p = end + 1;
y = strtol(p, &end, 0);
- if (end == p) {
+ if ((end == p) || (*end != '\0')) {
goto error;
}
} else {
+ if (*end != '\0') {
+ goto error;
+ }
x = borderwidth;
}
diff --git a/tests/menu.test b/tests/menu.test
index 152d2f4..f206a9e 100644
--- a/tests/menu.test
+++ b/tests/menu.test
@@ -3471,8 +3471,52 @@ test menu-22.5 {GetIndexFromCoords: mapped wide window} -setup {
} -cleanup {
deleteWindows
} -result 0
+test menu-22.6 {GetIndexFromCoords: syntax error in @x,y indices} -setup {
+ deleteWindows
+} -body {
+ menu .m
+ .m add command -label "First entry"
+ .m add command -label "Second entry"
+ .m add command -label "Last entry"
+ .m index @4bogus
+} -cleanup {
+ deleteWindows
+} -returnCodes error -result {bad menu entry index "@4bogus"}
+test menu-22.7 {GetIndexFromCoords: syntax error in @x,y indices} -setup {
+ deleteWindows
+} -body {
+ menu .m
+ .m add command -label "First entry"
+ .m add command -label "Second entry"
+ .m add command -label "Last entry"
+ .m index @10,4bogus
+} -cleanup {
+ deleteWindows
+} -returnCodes error -result {bad menu entry index "@10,4bogus"}
+test menu-22.8 {GetIndexFromCoords: syntax error in @x,y indices} -setup {
+ deleteWindows
+} -body {
+ menu .m
+ .m add command -label "First entry"
+ .m add command -label "Second entry"
+ .m add command -label "Last entry"
+ .m index @10,bogus
+} -cleanup {
+ deleteWindows
+} -returnCodes error -result {bad menu entry index "@10,bogus"}
+test menu-22.9 {GetIndexFromCoords: index type pecedence} -setup {
+ deleteWindows
+} -body {
+ menu .m -tearoff 0
+ .m add command -label "First entry"
+ .m add command -label "@42nd street"
+ .m add command -label "Last entry"
+ .m index "@42nd*" ; # shall be interpreted as a pattern, not as @42
+} -cleanup {
+ deleteWindows
+} -result {1}
-test menu-22.6 {tk_popup on separator entry} -setup {
+test menu-22.10 {tk_popup on separator entry} -setup {
deleteWindows
} -constraints {x11} -body {
menu .m1