chiark / gitweb /
bootchart: Do not try to access data for non-existing CPU's
authorPhilippe De Swert <philippe.deswert@jollamobile.com>
Sun, 28 Sep 2014 15:12:51 +0000 (18:12 +0300)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Sun, 28 Sep 2014 17:35:11 +0000 (19:35 +0200)
Cpu's are assigned normally, so starting at 0, so the MAX_CPU index will
always be one smaller than the actual number.

Found with Coverity.

src/bootchart/store.c

index 3099ff12083a8271df27ad24c4b646c037c404fd..9ea1b27de4b1666614170b91d55a8f212bb4ca11 100644 (file)
@@ -199,7 +199,7 @@ vmstat_next:
 
                 if (strstr(key, "cpu")) {
                         r = safe_atoi((const char*)(key+3), &c);
-                        if (r < 0 || c > MAXCPUS)
+                        if (r < 0 || c > MAXCPUS -1)
                                 /* Oops, we only have room for MAXCPUS data */
                                 break;
                         sampledata->runtime[c] = atoll(rt);