Commit 5e37ef5c authored by Li Dong's avatar Li Dong Committed by Namhyung Kim

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: 51cfe7a3 ("perf python: Avoid 2 leak sanitizer issues")
Signed-off-by: default avatarLi Dong <lidong@vivo.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: opensource.kernel@vivo.com
Link: https://lore.kernel.org/r/20230619082036.410-1-lidong@vivo.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 53fc25b7
......@@ -771,12 +771,12 @@ static void set_regs_in_dict(PyObject *dict,
int size = __sw_hweight64(attr->sample_regs_intr) * 28;
char *bf = malloc(size);
regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, sizeof(bf));
regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, size);
pydict_set_item_string_decref(dict, "iregs",
_PyUnicode_FromString(bf));
regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, sizeof(bf));
regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, size);
pydict_set_item_string_decref(dict, "uregs",
_PyUnicode_FromString(bf));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment