gdb_server: Add check for malloc fail

Change-Id: I623b30883042eae3253ed29de5c426da760dffa0
Signed-off-by: Evan Hunter <ehunter@broadcom.com>
Reviewed-on: http://openocd.zylin.com/2871
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
Evan Hunter 2015-07-16 17:44:17 +01:00 committed by Spencer Oliver
parent e3f8db54e6
commit 72466de399
1 changed files with 3 additions and 0 deletions

View File

@ -1159,6 +1159,9 @@ static int gdb_get_registers_packet(struct connection *connection,
assert(reg_packet_size > 0);
reg_packet = malloc(reg_packet_size + 1); /* plus one for string termination null */
if (reg_packet == NULL)
return ERROR_FAIL;
reg_packet_p = reg_packet;
for (i = 0; i < reg_list_size; i++) {