From: Marc Schink Date: Wed, 4 Apr 2018 07:50:40 +0000 (+0200) Subject: target: Fix segfault for 'mem2array' X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=abc270c8837bc7aad3f390e4e9858e4f652261b7;p=openocd 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 --- 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);