From: Nikolas Garofil Date: Wed, 18 Nov 2009 17:02:10 +0000 (+0100) Subject: Fix bug in $pid_cmdline X-Git-Url: http://git.maemo.org/git/?a=commitdiff_plain;h=4cfb042df9f3e035e610534a893566f3c83cbd61;p=monky Fix bug in $pid_cmdline --- diff --git a/src/proc.c b/src/proc.c index 50ee571..ae453b2 100644 --- a/src/proc.c +++ b/src/proc.c @@ -115,18 +115,22 @@ void print_pid_cmdline(struct text_object *obj, char *p, int p_max_size) char* buf; int i, bytes_read; - asprintf(&buf, PROCDIR "/%s/cmdline", obj->data.s); - strcpy(obj->data.s, buf); - free(buf); - buf = readfile(obj->data.s, &bytes_read, 1); - if(buf != NULL) { - for(i = 0; i < bytes_read-1; i++) { - if(buf[i] == 0) { - buf[i] = ' '; + if(*(obj->data.s) != 0) { + asprintf(&buf, PROCDIR "/%s/cmdline", obj->data.s); + strcpy(obj->data.s, buf); + free(buf); + buf = readfile(obj->data.s, &bytes_read, 1); + if(buf != NULL) { + for(i = 0; i < bytes_read-1; i++) { + if(buf[i] == 0) { + buf[i] = ' '; + } } + snprintf(p, p_max_size, "%s", buf); + free(buf); } - snprintf(p, p_max_size, "%s", buf); - free(buf); + } else { + NORM_ERR("$pid_cmdline didn't receive a argument"); } }