This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8812

-- gerrit

commit afa9a8204c7bd656380cdf203e5e748e760e36fa
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Sun Mar 23 15:16:56 2025 +0100

    target: avoid panic for syntax errors on target event configuration
    
    Syntax errors while using the commands configure or cget, to set
    or to query target event, can cause a panic in jimtcl function
    Jim_WrongNumArgs() when called with 'argc == 0'. E.g. typing:
            $target_name cget -event
            $target_name configure -event
            $target_name configure -event reset-end
    all trigger:
            JIM INTERPRETER PANIC: Jim_WrongNumArgs() called with argc=0
    
    Replace the call to Jim_WrongNumArgs() with direct settings of the
    result string.
    
    Change-Id: I080aff11dc79d36fe2f3929bef7dcd97aba460da
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/target/target.c b/src/target/target.c
index ce468cc90a..6928a38f10 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4963,7 +4963,8 @@ no_params:
                        break;
                case TCFG_EVENT:
                        if (goi->argc == 0) {
-                               Jim_WrongNumArgs(goi->interp, goi->argc, 
goi->argv, "-event ?event-name? ...");
+                               Jim_SetResultString(goi->interp,
+                                       "wrong # args: should be \"-event 
?event-name? ...\"", -1);
                                return JIM_ERR;
                        }
 
@@ -4975,12 +4976,14 @@ no_params:
 
                        if (goi->is_configure) {
                                if (goi->argc != 1) {
-                                       Jim_WrongNumArgs(goi->interp, 
goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
+                                       Jim_SetResultString(goi->interp,
+                                               "wrong # args: should be 
\"-event ?event-name? ?EVENT-BODY?\"", -1);
                                        return JIM_ERR;
                                }
                        } else {
                                if (goi->argc != 0) {
-                                       Jim_WrongNumArgs(goi->interp, 
goi->argc, goi->argv, "-event ?event-name?");
+                                       Jim_SetResultString(goi->interp,
+                                               "wrong # args: should be 
\"-event ?event-name?\"", -1);
                                        return JIM_ERR;
                                }
                        }

-- 

Reply via email to