From 325e0b0e33b0a6b9ca830c9d43777d0f5564d26f Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 31 Jan 2018 09:57:11 -0500 Subject: [PATCH] binpatch.lua: check for empty patches --- library/lua/binpatch.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/lua/binpatch.lua b/library/lua/binpatch.lua index d8e95b29f..0cae97e5b 100644 --- a/library/lua/binpatch.lua +++ b/library/lua/binpatch.lua @@ -17,6 +17,7 @@ local function load_patch(name) local old_bytes = {} local new_bytes = {} + local has_bytes = false for line in file:lines() do if string.match(line, '^%x+:') then @@ -34,10 +35,14 @@ local function load_patch(name) old_bytes[offset] = oldv new_bytes[offset] = newv + has_bytes = true end end file:close() + if not has_bytes then + return nil, 'no patch bytes found' + end return { name = name, old_bytes = old_bytes, new_bytes = new_bytes } end