Skip to content

Commit 5e37ef5

Browse files
lidongjsxnamhyung
authored andcommitted
tools: Fix incorrect calculation of object size by sizeof
What we need to calculate is the size of the object, not the size of the pointer. Fixed: 51cfe7a ("perf python: Avoid 2 leak sanitizer issues") Signed-off-by: Li Dong <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 53fc25b commit 5e37ef5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/perf/util/scripting-engines/trace-event-python.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,12 @@ static void set_regs_in_dict(PyObject *dict,
771771
int size = __sw_hweight64(attr->sample_regs_intr) * 28;
772772
char *bf = malloc(size);
773773

774-
regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, sizeof(bf));
774+
regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, size);
775775

776776
pydict_set_item_string_decref(dict, "iregs",
777777
_PyUnicode_FromString(bf));
778778

779-
regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, sizeof(bf));
779+
regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, size);
780780

781781
pydict_set_item_string_decref(dict, "uregs",
782782
_PyUnicode_FromString(bf));

0 commit comments

Comments
 (0)