]> granicus.if.org Git - procps-ng/commitdiff
libprocps-ng: readproc.c: some type conversion help
authorCraig Small <csmall@debian.org>
Tue, 24 Nov 2009 00:00:41 +0000 (11:00 +1100)
committerCraig Small <csmall@enc.com.au>
Sun, 18 Dec 2011 11:50:40 +0000 (22:50 +1100)
Return if unable to open /proc

A patch from Debian.

Backported-by: Sami Kerola <kerolasa@iki.fi>
proc/readproc.c

index b85cc887683ae31236e1a6d4c07ad7b8b94d91a0..c0345d7a05b0433d58d12a13e2961fe5c3bbfba5 100644 (file)
@@ -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 */