server/ipdbg: add error checks after allocating memory
Change-Id: Icf18a855eb66d2b09789a9ee27f5fbc4cd9afc89 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7605 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
3dfc0339fc
commit
babec0fafa
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue