Jelajahi Sumber

ram: Check for theoretical division by zero

Aaron Marcher 7 tahun lalu
induk
melakukan
ab4f24a612
1 mengubah file dengan 4 tambahan dan 0 penghapusan
  1. 4 0
      components/ram.c

+ 4 - 0
components/ram.c

@@ -36,6 +36,10 @@
 			return NULL;
 		}
 
+		if (total == 0) {
+			return NULL;
+		}
+
 		return bprintf("%d", 100 * ((total - free) -
 		                            (buffers + cached)) / total);
 	}