summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-26 01:27:56 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-26 01:27:56 +0000
commit3848774d33fd8a25f68c7522e0f956a7371060c5 (patch)
treeb2b5152aa5cf27816ddaf70ba7cbc8dcbbda1553 /src
parentfe465bd33e072383574ad5e02b7f8390a069a5a0 (diff)
downloadopenocd_libswd-3848774d33fd8a25f68c7522e0f956a7371060c5.tar.gz
openocd_libswd-3848774d33fd8a25f68c7522e0f956a7371060c5.tar.bz2
openocd_libswd-3848774d33fd8a25f68c7522e0f956a7371060c5.tar.xz
openocd_libswd-3848774d33fd8a25f68c7522e0f956a7371060c5.zip
SimonQian <simonqian@SimonQian.com>, reported by R.Doss:
This patch fixes a segfault when TDO was not received in XXR command: - allocate space for the value and mask anyway - clear the mask to zero to effectively skip the output comparison step git-svn-id: svn://svn.berlios.de/openocd/trunk@1915 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/svf/svf.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/svf/svf.c b/src/svf/svf.c
index caaacaba..62599c64 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -918,6 +918,27 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
}
buf_set_ones(xxr_para_tmp->mask, xxr_para_tmp->len);
}
+ // If TDO is absent, no comparison is needed, set the mask to 0
+ if (!(xxr_para_tmp->data_mask & XXR_TDO))
+ {
+ if (NULL == xxr_para_tmp->tdo)
+ {
+ if (ERROR_OK != svf_adjust_array_length(&xxr_para_tmp->tdo, i_tmp, xxr_para_tmp->len))
+ {
+ LOG_ERROR("fail to adjust length of array");
+ return ERROR_FAIL;
+ }
+ }
+ if (NULL == xxr_para_tmp->mask)
+ {
+ if (ERROR_OK != svf_adjust_array_length(&xxr_para_tmp->mask, i_tmp, xxr_para_tmp->len))
+ {
+ LOG_ERROR("fail to adjust length of array");
+ return ERROR_FAIL;
+ }
+ }
+ memset(xxr_para_tmp->mask, 0, (xxr_para_tmp->len + 7) >> 3);
+ }
// do scan if necessary
if (SDR == command)
{