Changeset

4418:70b5e533325d

util.debug: Fix potential traceback
author Matthew Wild <mwild1@gmail.com>
date Sat, 19 Nov 2011 22:40:30 +0000
parents 4417:33c149394dcb
children 4419:b1e49cc314cb 4424:1cbf3744300c
files util/debug.lua
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/util/debug.lua	Sat Nov 19 21:12:23 2011 +0500
+++ b/util/debug.lua	Sat Nov 19 22:40:30 2011 +0000
@@ -20,10 +20,12 @@
 
 local function get_upvalues_table(func)
 	local upvalues = {};
-	for upvalue_num = 1, math.huge do
-		local name, value = debug.getupvalue(func, upvalue_num);
-		if not name then break; end
-		table.insert(upvalues, { name = name, value = value });
+	if func then
+		for upvalue_num = 1, math.huge do
+			local name, value = debug.getupvalue(func, upvalue_num);
+			if not name then break; end
+			table.insert(upvalues, { name = name, value = value });
+		end
 	end
 	return upvalues;
 end