svf: improve robustness when processing invalid SVF files

Uninitialized argument value warnings reported by clang static
analizer.

Change-Id: I30af4900f517ffc0a7282689b58c7a224cdc080a
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4356
Tested-by: jenkins
riscv-compliance-dev
Paul Fertser 2018-01-18 11:59:10 +03:00
parent 3a32902987
commit 8b192df59a
1 changed files with 4 additions and 1 deletions

View File

@ -741,6 +741,9 @@ parse_char:
pos++; pos++;
} }
if (num == 0)
return ERROR_FAIL;
*num_of_argu = num; *num_of_argu = num;
return ERROR_OK; return ERROR_OK;
@ -1313,7 +1316,7 @@ XXR_common:
* SEC]] [ENDSTATE end_state] */ * SEC]] [ENDSTATE end_state] */
/* RUNTEST [run_state] min_time SEC [MAXIMUM max_time SEC] [ENDSTATE /* RUNTEST [run_state] min_time SEC [MAXIMUM max_time SEC] [ENDSTATE
* end_state] */ * end_state] */
if ((num_of_argu < 3) && (num_of_argu > 11)) { if ((num_of_argu < 3) || (num_of_argu > 11)) {
LOG_ERROR("invalid parameter of %s", argus[0]); LOG_ERROR("invalid parameter of %s", argus[0]);
return ERROR_FAIL; return ERROR_FAIL;
} }