diff options
author | Giulio Fieramosca <giulio@glgprograms.it> | 2022-11-03 20:38:20 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2022-11-15 21:35:12 +0000 |
commit | 2e9f04c11a5aeb9c7aa9d387f9f4d0e7c65a1f5b (patch) | |
tree | 5f189d0c83710f035cf002bd7dc9a7f789ed249c | |
parent | 2bad55bf83bcd4a24711a88b06971f3f828947bd (diff) | |
download | riscv-openocd-2e9f04c11a5aeb9c7aa9d387f9f4d0e7c65a1f5b.zip riscv-openocd-2e9f04c11a5aeb9c7aa9d387f9f4d0e7c65a1f5b.tar.gz riscv-openocd-2e9f04c11a5aeb9c7aa9d387f9f4d0e7c65a1f5b.tar.bz2 |
rtos/ThreadX: added check for NULL-named tasks
Thread name loading was not correctly handled if a ThreadX task has a NULL
name.
Signed-off-by: Giulio Fieramosca <giulio@glgprograms.it>
Change-Id: I03071930182bc2585b61ce5d8c67491710883dd6
Reviewed-on: https://review.openocd.org/c/openocd/+/7328
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
-rw-r--r-- | src/rtos/ThreadX.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c index 5f90eb6..5bdd007 100644 --- a/src/rtos/ThreadX.c +++ b/src/rtos/ThreadX.c @@ -370,16 +370,21 @@ static int threadx_update_threads(struct rtos *rtos) } /* Read the thread name */ - retval = - target_read_buffer(rtos->target, - name_ptr, - THREADX_THREAD_NAME_STR_SIZE, - (uint8_t *)&tmp_str); - if (retval != ERROR_OK) { - LOG_ERROR("Error reading thread name from ThreadX target"); - return retval; + tmp_str[0] = '\x00'; + + /* Check if thread has a valid name */ + if (name_ptr != 0) { + retval = + target_read_buffer(rtos->target, + name_ptr, + THREADX_THREAD_NAME_STR_SIZE, + (uint8_t *)&tmp_str); + if (retval != ERROR_OK) { + LOG_ERROR("Error reading thread name from ThreadX target"); + return retval; + } + tmp_str[THREADX_THREAD_NAME_STR_SIZE - 1] = '\x00'; } - tmp_str[THREADX_THREAD_NAME_STR_SIZE-1] = '\x00'; if (tmp_str[0] == '\x00') strcpy(tmp_str, "No Name"); |