diff options
Diffstat (limited to 'src/server/ipdbg.c')
-rw-r--r-- | src/server/ipdbg.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/server/ipdbg.c b/src/server/ipdbg.c index 755d051..69d0f57 100644 --- a/src/server/ipdbg.c +++ b/src/server/ipdbg.c @@ -315,6 +315,10 @@ static int ipdbg_shift_instr(struct ipdbg_hub *hub, uint32_t instr) } uint8_t *ir_out_val = calloc(DIV_ROUND_UP(tap->ir_length, 8), 1); + if (!ir_out_val) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; + } buf_set_u32(ir_out_val, 0, tap->ir_length, instr); struct scan_field fields; @@ -344,6 +348,10 @@ static int ipdbg_shift_vir(struct ipdbg_hub *hub) return ERROR_FAIL; uint8_t *dr_out_val = calloc(DIV_ROUND_UP(hub->virtual_ir->length, 8), 1); + if (!dr_out_val) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; + } buf_set_u32(dr_out_val, 0, hub->virtual_ir->length, hub->virtual_ir->value); struct scan_field fields; @@ -366,8 +374,21 @@ static int ipdbg_shift_data(struct ipdbg_hub *hub, uint32_t dn_data, uint32_t *u return ERROR_FAIL; uint8_t *dr_out_val = calloc(DIV_ROUND_UP(hub->data_register_length, 8), 1); + if (!dr_out_val) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; + } buf_set_u32(dr_out_val, 0, hub->data_register_length, dn_data); - uint8_t *dr_in_val = up_data ? calloc(DIV_ROUND_UP(hub->data_register_length, 8), 1) : NULL; + + uint8_t *dr_in_val = NULL; + if (up_data) { + dr_in_val = calloc(DIV_ROUND_UP(hub->data_register_length, 8), 1); + if (!dr_in_val) { + LOG_ERROR("Out of memory"); + free(dr_out_val); + return ERROR_FAIL; + } + } struct scan_field fields; ipdbg_init_scan_field(&fields, dr_in_val, hub->data_register_length, dr_out_val); |