chiark / gitweb /
bootchart: check return of strftime
[elogind.git] / src / bootchart / store.c
index ed46a503c672171e397b933e7f47f6a1f6d76bd7..3099ff12083a8271df27ad24c4b646c037c404fd 100644 (file)
@@ -192,12 +192,14 @@ vmstat_next:
 
         m = buf;
         while (m) {
+                int r;
+
                 if (sscanf(m, "%s %*s %*s %*s %*s %*s %*s %s %s", key, rt, wt) < 3)
                         goto schedstat_next;
 
                 if (strstr(key, "cpu")) {
-                        c = atoi((const char*)(key+3));
-                        if (c > MAXCPUS)
+                        r = safe_atoi((const char*)(key+3), &c);
+                        if (r < 0 || c > MAXCPUS)
                                 /* Oops, we only have room for MAXCPUS data */
                                 break;
                         sampledata->runtime[c] = atoll(rt);
@@ -399,7 +401,7 @@ schedstat_next:
                         continue;
 
                 ps->sample->next = new0(struct ps_sched_struct, 1);
-                if (!ps->sample) {
+                if (!ps->sample->next) {
                         log_oom();
                         exit(EXIT_FAILURE);
                 }