Fix for segfault in top_name stuff.
authorBrenden Matthews <brenden@diddyinc.com>
Wed, 20 Oct 2010 00:36:29 +0000 (17:36 -0700)
committerBrenden Matthews <brenden@diddyinc.com>
Wed, 20 Oct 2010 00:36:29 +0000 (17:36 -0700)
src/top.c

index 18b4ee6..29b169b 100644 (file)
--- a/src/top.c
+++ b/src/top.c
@@ -986,9 +986,11 @@ void print_top(struct text_object *obj, char *p, int p_max_size)
 
                switch (td->type) {
                        case TOP_NAME:
-                               width = MIN(p_max_size, (int)top_name_width + 1);
-                               snprintf(p, width + 1, "%-*s", width,
-                                               needed[td->num]->name);
+                               if (needed[td->num]->name) {
+                                       width = MIN(p_max_size, (int)top_name_width + 1);
+                                       snprintf(p, width + 1, "%-*s", width,
+                                                       needed[td->num]->name);
+                               }
                                break;
                        case TOP_CPU:
                                width = MIN(p_max_size, 7);