X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Ftop.c;h=29b169be7f326505268ff3f7deacad6fadb70f47;hb=2d2a163728283108eb78c11d7b02bf5c54d88ea4;hp=af195bbde9eaf5b12cf0b4de3d5d5fcd7fe91d11;hpb=f1b69e26a29bf8a5c3f91980dc4f15327d9e1b2a;p=monky diff --git a/src/top.c b/src/top.c index af195bb..29b169b 100644 --- a/src/top.c +++ b/src/top.c @@ -880,16 +880,22 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj) #else /* IOSTATS */ NORM_ERR("must be one of: name, cpu, pid, mem, time, mem_res, mem_vsize"); #endif /* IOSTATS */ + free(td->s); + free(obj->data.opaque); return 0; } if (n < 1 || n > 10) { NORM_ERR("invalid num arg for top. Must be between 1 and 10."); + free(td->s); + free(obj->data.opaque); return 0; } else { td->num = n - 1; } } else { NORM_ERR("invalid argument count for top"); + free(td->s); + free(obj->data.opaque); return 0; } return 1; @@ -980,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);