瀏覽代碼

ram: Check for theoretical division by zero

Aaron Marcher 7 年之前
父節點
當前提交
ab4f24a612
共有 1 個文件被更改,包括 4 次插入0 次删除
  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);
 	}