[PATCH 11/13] Guard against dereferencing undef

Anton Lundin glance at acc.umu.se
Tue Dec 10 15:53:35 UTC 2013


Introduce some harness in ProfileGraphicsView::plot_one_event, so we
detect bad stuff and bail, instead of dereferencing undef pointers.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 qt-ui/profilegraphics.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index f99fd4d..18e97da 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -956,7 +956,7 @@ void ProfileGraphicsView::plot_one_event(struct event *ev)
 {
 	int i;
 	struct plot_info *pi = &gc.pi;
-	struct plot_data *entry;
+	struct plot_data *entry = NULL;
 
 	/* is plotting of this event disabled? */
 	if (ev->name) {
@@ -981,6 +981,10 @@ void ProfileGraphicsView::plot_one_event(struct event *ev)
 			break;
 	}
 
+	/* If we didn't find the right event, don't dereference null */
+	if (entry == NULL)
+		return;
+
 	/* draw a little triangular marker and attach tooltip */
 
 	int x = SCALEXGC(ev->time.seconds);
-- 
1.8.3.2



More information about the subsurface mailing list