Skip to content

Commit

Permalink
Fix: NullReference in stack evaluation in xamarin
Browse files Browse the repository at this point in the history
  • Loading branch information
neolithos committed Oct 8, 2018
1 parent 7a689c2 commit e054e91
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions NeoLua/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private string GetChunkName()
{
var chunkName = info.ChunkName;
var methodName = Method.Name;

return methodName.StartsWith(chunkName)
? chunkName
: chunkName + "#" + methodName;
Expand All @@ -330,19 +330,19 @@ public LuaStackFrameType Type
} // func Type

/// <summary></summary>
public string MethodName { get { return info == null ? Method.Name : GetChunkName(); } }
public string MethodName => info == null ? Method.Name : GetChunkName();
/// <summary></summary>
public MethodBase Method { get { return frame.GetMethod(); } }
public MethodBase Method => frame.GetMethod();
/// <summary></summary>
public int ILOffset { get { return frame.GetILOffset(); } }
public int ILOffset => frame.GetILOffset();
/// <summary></summary>
public int NativeOffset { get { return frame.GetNativeOffset(); } }
public int NativeOffset => frame.GetNativeOffset();
/// <summary></summary>
public string FileName { get { return info == null ? frame.GetFileName() : info.FileName; } }
public string FileName => info?.FileName ?? frame.GetFileName();
/// <summary></summary>
public int ColumnNumber { get { return info == null ? frame.GetFileColumnNumber() : info.Column; } }
public int ColumnNumber => info?.Column ?? frame.GetFileColumnNumber();
/// <summary></summary>
public int LineNumber { get { return info == null ? frame.GetFileLineNumber() : info.Line; } }
public int LineNumber => info == null ? frame.GetFileLineNumber() : info.Line;

string ILuaDebugInfo.ChunkName => MethodName;
int ILuaDebugInfo.Line => LineNumber;
Expand Down Expand Up @@ -392,7 +392,7 @@ public void UpdateStackTrace(LuaStackFrame[] newStackTrace)
public IEnumerator<LuaStackFrame> GetEnumerator()
{
var length = Count;
for (int i = 0; i < length; i++)
for (var i = 0; i < length; i++)
yield return stackTrace[i];
} // func GetEnumerator

Expand Down Expand Up @@ -562,7 +562,7 @@ public static void UnwindException(Exception ex, Func<ILuaDebugInfo> createDebug

// add trace point
luaFrames.Add(new LuaStackFrame(trace.GetFrame(trace.FrameCount - 1), createDebugInfo()));

currentData.UpdateStackTrace(luaFrames.ToArray());
} // func UnwindException
} // class LuaExceptionData
Expand Down
2 changes: 1 addition & 1 deletion NeoLua/Lua.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public static LuaChunk GetChunkFromMethodName(string name)
/// <param name="mi"></param>
/// <returns></returns>
public static LuaChunk GetChunkFromMethodInfo(MethodBase mi)
=> GetChunkFromMethodName(mi.Name);
=> mi != null ? GetChunkFromMethodName(mi.Name) : null;

#endregion

Expand Down
2 changes: 1 addition & 1 deletion NeoLua/LuaDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Expression GetLineInfoExpression(DebugInfoExpression exprDebugInfo)
var oldFileName = FileNameConstant.Value as string;
var newFileName = exprDebugInfo.Document?.FileName;
if (oldFileName != newFileName)
FileNameConstant = Expression.Constant(newFileName);
FileNameConstant = Expression.Constant(newFileName, typeof(string));

if (exprDebugInfo.StartLine == 16707566)
{
Expand Down

0 comments on commit e054e91

Please sign in to comment.