ram: Check for theoretical division by zero
authorAaron Marcher <me@drkhsh.at>
Fri, 6 Jul 2018 21:38:12 +0000 (23:38 +0200)
committerAaron Marcher <me@drkhsh.at>
Fri, 6 Jul 2018 21:38:12 +0000 (23:38 +0200)
components/ram.c

index 74bf337ae601972ff35a772489565525c4021e49..8688349057871d81bad4b7d608f65a7244170916 100644 (file)
                        return NULL;
                }
 
+               if (total == 0) {
+                       return NULL;
+               }
+
                return bprintf("%d", 100 * ((total - free) -
                                            (buffers + cached)) / total);
        }