Guard against dereferencing undef

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@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2013-12-11 00:53:35 +01:00 committed by Dirk Hohndel
parent 82b86fe924
commit 022e2d0d9d

View file

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