From bab6db1fd98e3f31f6cd1981756f95773ce9f256 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Harboe?= Date: Sat, 29 Oct 2011 17:37:42 +0200 Subject: [PATCH] gdb_server: assert to avoid malloc(0) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I6ae3e007f4aa768f8bc64de78351750138f12e53 Signed-off-by: Øyvind Harboe Reviewed-on: http://openocd.zylin.com/135 Tested-by: jenkins Reviewed-by: Andreas Fritiofson Reviewed-by: Øyvind Harboe --- src/server/gdb_server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 5eb6cac4..7c55e7cd 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1061,6 +1061,8 @@ static int gdb_get_registers_packet(struct connection *connection, reg_packet_size += reg_list[i]->size; } + assert(reg_packet_size > 0); + reg_packet = malloc(DIV_ROUND_UP(reg_packet_size, 8) * 2); reg_packet_p = reg_packet; -- 2.39.5