summaryrefslogtreecommitdiff
path: root/mesecons/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'mesecons/util.lua')
-rw-r--r--mesecons/util.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/mesecons/util.lua b/mesecons/util.lua
index 3cdeb64..234775b 100644
--- a/mesecons/util.lua
+++ b/mesecons/util.lua
@@ -164,7 +164,9 @@ end
function mesecon.get_bit(binary,bit)
bit = bit or 1
- local c = binary:len()-(bit-1)
+ local len = binary:len()
+ if bit > len then return false end
+ local c = len-(bit-1)
return binary:sub(c,c) == "1"
end