assert(reg_packet_size > 0);
- reg_packet = malloc(reg_packet_size);
+ reg_packet = malloc(reg_packet_size + 1); /* plus one for string termination null */
reg_packet_p = reg_packet;
for (i = 0; i < reg_list_size; i++) {
if (!reg_list[reg_num]->valid)
reg_list[reg_num]->type->get(reg_list[reg_num]);
- reg_packet = malloc(DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2);
+ reg_packet = malloc(DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2 + 1); /* plus one for string termination null */
gdb_str_to_target(target, reg_packet, reg_list[reg_num]);