From: Evan Hunter Date: Thu, 16 Jul 2015 16:44:17 +0000 (+0100) Subject: gdb_server: Add check for malloc fail X-Git-Tag: v0.10.0-rc1~455 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=72466de39931cbe872db367c878c5ed17a4b67f3;p=openocd gdb_server: Add check for malloc fail Change-Id: I623b30883042eae3253ed29de5c426da760dffa0 Signed-off-by: Evan Hunter Reviewed-on: http://openocd.zylin.com/2871 Tested-by: jenkins Reviewed-by: Spencer Oliver --- diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 4a33a302..780359ea 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -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++) {