From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> If traceeval_init() is passed NULL for vals, it can crash because he teval->timestamp_idx is not updated and stays at zero. Then the check for timestamp will iterate the NULL array of vals and crash. Move the initialization of teval->timestamp_idx right after the teval is allocated and do not depend on the val check to update it. Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- src/histograms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/histograms.c b/src/histograms.c index 572f33eb3ac6..f77afc3a86a1 100644 --- a/src/histograms.c +++ b/src/histograms.c @@ -338,8 +338,6 @@ static int check_vals(struct traceeval *teval, struct traceeval_type *vals, int vals[i].flags |= TRACEEVAL_FL_STAT; vals[i].index = i; } - if (!ts_found) - teval->timestamp_idx = -1; return 0; } @@ -402,6 +400,8 @@ struct traceeval *traceeval_init_data_size(struct traceeval_type *keys, goto fail; } + teval->timestamp_idx = -1; + ret = check_keys(keys, nr_keys); if (ret < 0) goto fail_release; -- 2.42.0