From cd8316ea4c30459f613265cb3d59d8f66b3e6e9f Mon Sep 17 00:00:00 2001 From: peelz Date: Fri, 16 Sep 2022 22:55:49 -0400 Subject: [PATCH] Fix NRE in LuaUserData.GetType --- .../SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs index 94b74963e..914caefa9 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -11,8 +11,10 @@ namespace Barotrauma { public static Type GetType(string typeName) { + if (typeName == null || typeName.Length == 0) return null; + var byRef = false; - if (typeName.StartsWith("out ") || typeName.StartsWith("ref ")) + if (typeName.StartsWith("out ") || typeName.StartsWith("ref ")) { typeName = typeName.Remove(0, 4); byRef = true; @@ -266,4 +268,4 @@ namespace Barotrauma return CreateUserDataFromDescriptor(scriptObject, descriptor); } } -} \ No newline at end of file +}