From: Paul Fertser Date: Tue, 25 Feb 2014 17:22:11 +0000 (+0400) Subject: flash/nor/tcl: fix segfault on write_image misuse X-Git-Tag: v0.8.0-rc1~35 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=58256d48358ab695e970b5e61546aecb366ad914;p=openocd flash/nor/tcl: fix segfault on write_image misuse "flash write_image (unlock|erase)" (without filename) was causing segmentation fault in strcmp(). This patch fixes it. Change-Id: Ia3b8c796f4107621d78605c02d2b8e123b1b207b Reported-by: ajkroll][ Signed-off-by: Paul Fertser Reviewed-on: http://openocd.zylin.com/1970 Tested-by: jenkins Reviewed-by: Spencer Oliver --- diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 916ebf73..32a666cc 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -349,14 +349,11 @@ COMMAND_HANDLER(handle_flash_write_image_command) int retval; - if (CMD_ARGC < 1) - return ERROR_COMMAND_SYNTAX_ERROR; - /* flash auto-erase is disabled by default*/ int auto_erase = 0; bool auto_unlock = false; - for (;; ) { + while (CMD_ARGC) { if (strcmp(CMD_ARGV[0], "erase") == 0) { auto_erase = 1; CMD_ARGV++;