Xinqi Bao's Git

ram: Check for theoretical division by zero
authorAaron Marcher <[email protected]>
Fri, 6 Jul 2018 21:38:12 +0000 (23:38 +0200)
committerAaron Marcher <[email protected]>
Fri, 6 Jul 2018 21:38:12 +0000 (23:38 +0200)
components/ram.c

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