mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
rtos: chibios: replace malloc+sprintf with alloc_printf
This makes it safer and simpler at the same time. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Change-Id: Ie294f1f6033ffc9f46b39210e2f7fc2f648e80ac Reviewed-on: https://review.openocd.org/c/openocd/+/8598 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
committed by
Tomas Vanek
parent
a510d51a78
commit
ce38758e3d
@@ -421,9 +421,11 @@ static int chibios_update_threads(struct rtos *rtos)
|
||||
else
|
||||
state_desc = "Unknown";
|
||||
|
||||
curr_thrd_details->extra_info_str = malloc(strlen(
|
||||
state_desc)+8);
|
||||
sprintf(curr_thrd_details->extra_info_str, "State: %s", state_desc);
|
||||
curr_thrd_details->extra_info_str = alloc_printf("State: %s", state_desc);
|
||||
if (!curr_thrd_details->extra_info_str) {
|
||||
LOG_ERROR("Could not allocate space for thread state description");
|
||||
return -1;
|
||||
}
|
||||
|
||||
curr_thrd_details->exists = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user