perf symbol: Avoid an undefined behavior warning
Ian Rogers
reviewerPATCH 1/1 perf symbol: Avoid an undefined behavior warning
The node (nd) may be NULL and pointer arithmetic on NULL is undefined behavior. Move the computation of next below the NULL check on the node.
Signed-off-by Ian Rogers <[email protected]>
--- tools/perf/util/symbol.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/symbol.c +1 -2
@@ -202,11 +202,10 @@ void symbols__fixup_duplicate(struct rb_root_cached *symbols) curr = rb_entry(nd, struct symbol, rb_node); again: nd =rb_next (&curr->rb_node); - next = rb_entry(nd, struct symbol, rb_node); -if (!nd)break ; + next = rb_entry(nd, struct symbol, rb_node);if (curr->start != next->start)continue ;
Signature · 1 line
2.42.0.459.ge4e396fd5e-goog
Quoted 6 lines · Ian Rogers
The node (nd) may be NULL and pointer arithmetic on NULL is undefined behavior. Move the computation of next below the NULL check on the node.
Signed-off-by Ian Rogers <[email protected]>
Applied to perf-tools-next, thanks!
Namhyung