[sysprof/wip/chergert/sysprof-3] libsysprof-ui: protect against NULL



commit 77378a41d6f304fb1c7886c9bff1bd267f393a60
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 13 22:53:17 2019 -0700

    libsysprof-ui: protect against NULL

 src/libsysprof-ui/pointcache.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/libsysprof-ui/pointcache.c b/src/libsysprof-ui/pointcache.c
index b760987..6c902a8 100644
--- a/src/libsysprof-ui/pointcache.c
+++ b/src/libsysprof-ui/pointcache.c
@@ -99,7 +99,13 @@ point_cache_get_points (PointCache *self,
 {
   GArray *ar;
 
-  ar = g_hash_table_lookup (self->sets, GUINT_TO_POINTER (set_id));
-  *n_points = ar->len;
-  return &g_array_index (ar, const Point, 0);
+  *n_points = 0;
+
+  if ((ar = g_hash_table_lookup (self->sets, GUINT_TO_POINTER (set_id))))
+    {
+      *n_points = ar->len;
+      return &g_array_index (ar, const Point, 0);
+    }
+
+  return NULL;
 }


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