From abc270c8837bc7aad3f390e4e9858e4f652261b7 Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Wed, 4 Apr 2018 09:50:40 +0200 Subject: [PATCH] target: Fix segfault for 'mem2array' Call 'mem2array' without arguments to reproduce the segmentation fault. Change-Id: I02bf46cc8bd317abbb721a8c75d7cbfac99eb34e Signed-off-by: Marc Schink Reviewed-on: http://openocd.zylin.com/4534 Tested-by: jenkins Reviewed-by: Antonio Borneo Reviewed-by: Christopher Head --- src/target/target.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/target/target.c b/src/target/target.c index 1ca6c8e5..591b9ea2 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4131,8 +4131,9 @@ static int target_mem2array(Jim_Interp *interp, struct target *target, int argc, * argv[3] = memory address * argv[4] = count of times to read */ + if (argc < 4 || argc > 5) { - Jim_WrongNumArgs(interp, 1, argv, "varname width addr nelems [phys]"); + Jim_WrongNumArgs(interp, 0, argv, "varname width addr nelems [phys]"); return JIM_ERR; } varname = Jim_GetString(argv[0], &len); -- 2.39.5