libtracefs: Fix add_sort_key()
PATCH 1/1 libtracefs: Fix add_sort_key()
The histogram can have no 'values'. A check is required in order to prevent segfault.
Fixes 5d1c2ea(libtracefs: Implement API to create / modify and display histograms)
Signed-off-by Yordan Karadzhov (VMware) <[email protected]>
--- src/tracefs-hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/tracefs-hist.c +1 -1
@@ -364,7 +364,7 @@ add_sort_key(struct tracefs_hist *hist, const char *sort_key, char **list)break ; } -if (!key_list[i]) { +if (!key_list[i] && val_list) {for (i =0 ; val_list[i]; i++) {if (strcmp (val_list[i], sort_key) ==0 )break ;
Signature · 1 line
2.30.2