summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-12 06:17:22 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-12 06:17:22 +0000
commit9bbd933eaeed8928ab0648424a7032fadd6ead63 (patch)
tree9754b1fdeb4e8ffd9db31c08fc70d7fdfff74c91
parent30a17f0bb402ae95bfde948dea10fc7ae7d6c4ba (diff)
downloadopenocd_libswd-9bbd933eaeed8928ab0648424a7032fadd6ead63.tar.gz
openocd_libswd-9bbd933eaeed8928ab0648424a7032fadd6ead63.tar.bz2
openocd_libswd-9bbd933eaeed8928ab0648424a7032fadd6ead63.tar.xz
openocd_libswd-9bbd933eaeed8928ab0648424a7032fadd6ead63.zip
fix ancient bug & SEGFAULT in irscan
git-svn-id: svn://svn.berlios.de/openocd/trunk@1751 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r--src/jtag/jtag.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index 3d43bc9e..27fe5248 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -2889,9 +2889,11 @@ static int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, c
}
}
- fields = malloc(sizeof(scan_field_t) * argc / 2);
+ int num_fields= num_fields;
- for (i = 0; i < argc / 2; i++)
+ fields = malloc(sizeof(scan_field_t) * num_fields);
+
+ for (i = 0; i < num_fields; i++)
{
tap = jtag_TapByString( args[i*2] );
if (tap==NULL)
@@ -2901,19 +2903,20 @@ static int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, c
}
int field_size = tap->ir_length;
fields[i].tap = tap;
+ fields[i].num_bits = field_size;
fields[i].out_value = malloc(CEIL(field_size, 8));
buf_set_u32(fields[i].out_value, 0, field_size, strtoul(args[i*2+1], NULL, 0));
fields[i].in_value = NULL;
}
- jtag_add_ir_scan(argc / 2, fields, TAP_INVALID);
+ jtag_add_ir_scan(num_fields, fields, TAP_INVALID);
/* did we have an endstate? */
if (endstate != TAP_INVALID)
jtag_add_end_state(endstate);
jtag_execute_queue();
- for (i = 0; i < argc / 2; i++)
+ for (i = 0; i < num_fields; i++)
free(fields[i].out_value);
free (fields);