From 049e9290cff65235632cb68df71470bdf9127e6d Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Thu, 4 Feb 2021 10:30:00 +0100 Subject: [PATCH] spdk_top: fix app crashing on tab selection with TAB key Fixes spdk_top crashing problem upon selecting a row in one tab, then switching with TAB key to a different tab with fewer rows and calling pop-up details window with ENTER key. Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6367 (master) (cherry picked from commit 6a343482193bf728d3e82bd5b1994bf767533aef) Change-Id: I52c5729eca0ce0eaad88767ff3add471a780140a Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6729 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- app/spdk_top/spdk_top.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index c996235f4..402c2a576 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -2027,6 +2027,7 @@ show_thread(uint8_t current_page) get_data(); + assert(thread_number < g_threads_stats.threads.threads_count); for (i = 0; i < g_threads_stats.threads.threads_count; i++) { thread_info[i] = &g_threads_stats.threads.thread_info[i]; } @@ -2067,6 +2068,7 @@ show_core(uint8_t current_page) get_data(); + assert(core_number < g_cores_stats.cores.cores_count); for (i = 0; i < g_cores_stats.cores.cores_count; i++) { core_info[i] = &g_cores_stats.cores.core[i]; } @@ -2178,6 +2180,7 @@ show_poller(uint8_t current_page) get_data(); prepare_poller_data(current_page, pollers, &count, current_page); + assert(poller_number < count); poller_win = newwin(POLLER_WIN_HEIGHT, POLLER_WIN_WIDTH, (g_max_row - poller_counter) / 2, (g_max_col - POLLER_WIN_HOR_POS) / 2); @@ -2300,6 +2303,7 @@ show_stats(void) } else { active_tab = THREADS_TAB; } + g_selected_row = 0; current_page = 0; switch_tab(active_tab); break;