From: Evgeniy Naydanov Date: Fri, 14 Feb 2025 16:29:08 +0000 (+0300) Subject: rtos/rtos: handle OOM in `rtos_thread_packet()` X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7ec11e52387390ea1fab510f10fc6cd0ed200ef5;p=users%2Fborneoa%2Fopenocd-next.git rtos/rtos: handle OOM in `rtos_thread_packet()` Return an error in case `calloc()` fails. Change-Id: Ibb21a62991be83be8b219887953ccf27156f8af5 Signed-off-by: Evgeniy Naydanov Reviewed-on: https://review.openocd.org/c/openocd/+/8763 Tested-by: jenkins Reviewed-by: zapb --- diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c index f218f6369..2c563d522 100644 --- a/src/rtos/rtos.c +++ b/src/rtos/rtos.c @@ -362,6 +362,10 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa str_size += strlen(detail->extra_info_str); char *tmp_str = calloc(str_size + 9, sizeof(char)); + if (!tmp_str) { + LOG_ERROR("Out of memory"); + return ERROR_FAIL; + } char *tmp_str_ptr = tmp_str; if (detail->thread_name_str)