Message ID | 20210923092110.84812-1-y.karadz@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 7103dcceb469f27795946f928c6851a33409d5b1 |
Headers | show |
Series | libtracefs: Fix add_sort_key() | expand |
diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c index eeb8374..c112b68 100644 --- a/src/tracefs-hist.c +++ b/src/tracefs-hist.c @@ -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;
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) <y.karadz@gmail.com> --- src/tracefs-hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)