[PATCH 1/2] trace-cruncher: Fix segfault in PyTraceHist_read()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 src/ftracepy-utils.c | 3 +++
 1 file changed, 3 insertions(+)

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);
-- 
2.32.0




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux