]> git.sur5r.net Git - openocd/commitdiff
gdb_server: Add check for malloc fail
authorEvan Hunter <ehunter@broadcom.com>
Thu, 16 Jul 2015 16:44:17 +0000 (17:44 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Thu, 6 Aug 2015 12:16:17 +0000 (13:16 +0100)
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>
src/server/gdb_server.c

index 4a33a3022be34fa8290ccb414e761f38d055886c..780359ea4510ac1ee344fcf6438834b9e338fdf2 100644 (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++) {