diff --git a/components/esp_gdbstub/src/gdbstub.c b/components/esp_gdbstub/src/gdbstub.c index 7ce49c63ac..cc5288aafd 100644 --- a/components/esp_gdbstub/src/gdbstub.c +++ b/components/esp_gdbstub/src/gdbstub.c @@ -847,7 +847,7 @@ static bool get_task_handle(size_t index, TaskHandle_t *handle) static eTaskState get_task_state(size_t index) { eTaskState result = eReady; - TaskHandle_t handle; + TaskHandle_t handle = NULL; get_task_handle(index, &handle); if (gdb_debug_int == false) { result = eTaskGetState(handle); @@ -858,7 +858,9 @@ static eTaskState get_task_state(size_t index) static int get_task_cpu_id(size_t index) { TaskHandle_t handle; - get_task_handle(index, &handle); + if (!get_task_handle(index, &handle)) { + return -1; + } BaseType_t core_id = xTaskGetAffinity(handle); return (int)core_id; }