From 1ae6748835396bf66a5825b38369077b34582f9a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 25 Nov 2015 20:49:41 +0100 Subject: util.cache: Make sure cache size is specified as an integer --- util/cache.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util') diff --git a/util/cache.lua b/util/cache.lua index 9453697c..32670751 100644 --- a/util/cache.lua +++ b/util/cache.lua @@ -2,6 +2,8 @@ local cache_methods = {}; local cache_mt = { __index = cache_methods }; local function new(size) + size = assert(tonumber(size), "cache size must be a number"); + size = math.floor(size); assert(size > 0, "cache size must be greater than zero"); local data = {}; return setmetatable({ data = data, count = 0, size = size, head = nil, tail = nil }, cache_mt); -- cgit v1.2.3