Message ID | 20211216132921.239628-1-y.karadz@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [1/2] trace-cruncher: Fix segfault in PyTraceHist_read() | expand |
diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index a735d88..1b1f350 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -978,6 +978,9 @@ PyObject *PyTraceHist_read(PyTraceHist *self, PyObject *args, PyObject *kwargs) { char *data = hist_read(self, args, kwargs); + if (!data) + return NULL; + PyObject *ret = PyUnicode_FromString(data); free(data);
A NULL pointer can be returned when reading from the 'hist' file of the event. This may happen if the histogram is not initialized. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/ftracepy-utils.c | 3 +++ 1 file changed, 3 insertions(+)