diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-09-16 09:44:38 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:53 +1000 |
commit | 03f330c8223deddc8050205d3c275e6e260684b4 (patch) | |
tree | 95718949e8769538163a1bf00ef999ddbcc945cb | |
parent | 2f28a3cc9b01b61206c94f09f8ad1a59caaf7077 (diff) | |
download | jimtcl-03f330c8223deddc8050205d3c275e6e260684b4.zip jimtcl-03f330c8223deddc8050205d3c275e6e260684b4.tar.gz jimtcl-03f330c8223deddc8050205d3c275e6e260684b4.tar.bz2 |
Fix crash on expand of empty arg
Found by the clang static analyser
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim.c | 12 | ||||
-rw-r--r-- | regtest.tcl | 6 |
2 files changed, 12 insertions, 6 deletions
@@ -9602,12 +9602,12 @@ int Jim_EvalObj(Jim_Interp *interp, Jim_Obj *scriptObjPtr) argc = eargc; argv = eargv; j = argc; - if (argc == 0) { - /* Nothing to do with zero args. */ - Jim_Free(eargv); - continue; - } } + + if (argc == 0) { + goto empty_expansion; + } + /* Lookup the command to call */ cmd = Jim_GetCommand(interp, argv[0], JIM_ERRMSG); if (cmd != NULL) { @@ -9639,7 +9639,7 @@ int Jim_EvalObj(Jim_Interp *interp, Jim_Obj *scriptObjPtr) for (j = 0; j < argc; j++) { Jim_DecrRefCount(interp, argv[j]); } - + empty_expansion: if (argv != sargv) { Jim_Free(argv); argv = NULL; diff --git a/regtest.tcl b/regtest.tcl index 16b691e..05f0ac6 100644 --- a/regtest.tcl +++ b/regtest.tcl @@ -86,6 +86,12 @@ set x "switch -0 \$on \\" lindex $x 1 puts "TEST 13 PASSED" +# REGTEST 14 +# 14 Sep 2010 - command expands to nothing +eval "{*}{}" +puts "TEST 14 PASSED" + + # TAKE THE FOLLOWING puts AS LAST LINE puts "--- ALL TESTS PASSED ---" |