aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-05-27 22:39:39 +1000
committerSteve Bennett <steveb@workware.net.au>2020-05-27 22:41:58 +1000
commit8c123720e88580b4693de1ef192e28616f3944f7 (patch)
treed6745358c488242e3cf34bb93cc3483539845480
parentaa27b2aed1f7ff0056d3299655df1cd539af0444 (diff)
downloadjimtcl-8c123720e88580b4693de1ef192e28616f3944f7.zip
jimtcl-8c123720e88580b4693de1ef192e28616f3944f7.tar.gz
jimtcl-8c123720e88580b4693de1ef192e28616f3944f7.tar.bz2
lsearch: handle too few args with -command
Fixes #155 Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--jim.c4
-rw-r--r--regtest.tcl6
2 files changed, 10 insertions, 0 deletions
diff --git a/jim.c b/jim.c
index 08c448b..6e0cdb7 100644
--- a/jim.c
+++ b/jim.c
@@ -12292,6 +12292,10 @@ static int Jim_LsearchCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *
}
}
+ argc -= i;
+ if (argc < 2) {
+ goto wrongargs;
+ }
argv += i;
if (opt_all) {
diff --git a/regtest.tcl b/regtest.tcl
index a46b849..14ce59f 100644
--- a/regtest.tcl
+++ b/regtest.tcl
@@ -350,6 +350,12 @@ puts "TEST 50 PASSED"
catch {expr {2 && "abc$"}}
puts "TEST 51 PASSED"
+# REGTEST 52
+# lsearch -command with too few args
+catch {lsearch -all -command abc def}
+puts "TEST 52 PASSED"
+
+
# TAKE THE FOLLOWING puts AS LAST LINE
puts "--- ALL TESTS PASSED ---"