[PATCH] libtracefs: Fix add_sort_key()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 src/tracefs-hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.30.2




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux