Skip to content

Commit 21ce931

Browse files
captain5050namhyung
authored andcommitted
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]> Cc: James Clark <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 999b81b commit 21ce931

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

tools/perf/util/symbol.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,10 @@ void symbols__fixup_duplicate(struct rb_root_cached *symbols)
202202
curr = rb_entry(nd, struct symbol, rb_node);
203203
again:
204204
nd = rb_next(&curr->rb_node);
205-
next = rb_entry(nd, struct symbol, rb_node);
206-
207205
if (!nd)
208206
break;
209207

208+
next = rb_entry(nd, struct symbol, rb_node);
210209
if (curr->start != next->start)
211210
continue;
212211

0 commit comments

Comments
 (0)