From 16329a7c3cba94e3f13f0cd52106fcde3a2c79dc Mon Sep 17 00:00:00 2001 From: Craig Small Date: Tue, 24 Nov 2009 11:00:41 +1100 Subject: [PATCH] libprocps-ng: readproc.c: some type conversion help Return if unable to open /proc A patch from Debian. Backported-by: Sami Kerola --- proc/readproc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proc/readproc.c b/proc/readproc.c index b85cc887..c0345d7a 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -218,7 +218,7 @@ ENTER(0x220); // examine a field name (hash and compare) base: if(unlikely(!*S)) break; - entry = table[63 & (asso[S[3]] + asso[S[2]] + asso[S[0]])]; + entry = table[63 & (asso[(int)S[3]] + asso[(int)S[2]] + asso[(int)S[0]])]; colon = strchr(S, ':'); if(unlikely(!colon)) break; if(unlikely(colon[1]!='\t')) break; @@ -1239,6 +1239,8 @@ proc_t** readproctab(int flags, ...) { else PT = openproc(flags); va_end(ap); + if (!PT) + return 0; do { /* read table: */ tab = xrealloc(tab, (n+1)*sizeof(proc_t*));/* realloc as we go, using */ tab[n] = readproc_direct(PT, NULL); /* final null to terminate */